Skip to content

Simple Demo CRUD .NET 6 - Unit Testing Web Api. Setting up a simple Github Workflow.

Notifications You must be signed in to change notification settings

federicodiluca/NetCore-GithubWorkflows-Demo

Repository files navigation

Testing Github Workflows

Simple Demo CRUD .NET 6 - Unit Testing Web Api.
Setting up a simple Github Workflow for Unit Testing following the Github Guide.
Just create a Workflow file

Testing Badge

You may want to create a simple workflow badge to check the testing result after every commit.

Test

Once you created the .yml file you just need to go to the Actions tab, select your action and click on "Create status badge".
Copy-paste the generated code in the readme.

image

Here it is the Microsoft reference to create the result badge.

Publish Nuget Package

Here I also raw-tested a publish package workflow wich runs on tag pushes like "v1.0.13" (regex). This is helpful if you want to automate the publication of a package.
Instead of just build the project, pack it and call the nuget-push api setting up a github secret.

    - name: Pack
      run: dotnet pack <YOUR_PROJECT>.csproj --configuration Release --no-build --output .
    - name: Push Nuget
      run: dotnet nuget push <YOUR_PROJECT>.${VERSION}.nupkg --source <API_URL> --api-key ${NUGET_API_KEY}
      env:
        NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
    - name: Success Message
      run: echo "Version ${VERSION} published! 🎉"

About

Simple Demo CRUD .NET 6 - Unit Testing Web Api. Setting up a simple Github Workflow.

Topics

Resources

Stars

Watchers

Forks

Languages