Skip to content

rezabmirzaei/dotnet-api-template

Repository files navigation

.NET API Template with GitHub Actions workflow

  • A simple .NET API
  • CI/CD pipeline (GitHub Actions) to build image and upload to Docker Hub
    • Workflow created using GitHub Action's default template for creating a Docker container, then expanded

Prerequisites

Test locally

To build a Docker-image, in root folder, open terminal and run:

  • docker build -t <YOUR_DOCKER_USERNAME>/dotnet-api-template .

To run image, open terminal and run:

CI/CD with GitHub Actions

The workflow is defined in docker-image.yml. It will run automatically on every push to this branch.

Setup

In you Docker Hub account, create an access token. Remember the value! You will need it when configuring the GitHub Actions workflow.

In GitHub, in the repository for your API, under Settings > Secrets and variables > Actions; create two new secrets:

  • DOCKERHUB_USERNAME containing your Docker Hub username
  • DOCKERHUB_TOKEN containing the access token you created for you Docker Hub account

These values will be used in the automated workflow to build and push your image to <DOCKERHUB_USERNAME>/dotnet-api-tamplate:latest

Test build/push to Docker Hub

  • Make a change in the API and push the changes to your repository.
  • In GitHub, in your repository for this project, monitor the build process under the Actions tab.
  • When done, check your Docker Hub account under Repositories and you should see a new image of this API.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published