diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index aa1fe3a..2e85dd1 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -14,6 +14,7 @@ on: env: DOTNET_VERSION: 8.0.x + PACKAGE_NAME: nanotaboada/dotnet-samples-aspnetcore-webapi jobs: build: @@ -104,3 +105,35 @@ jobs: with: project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} coverage-reports: cobertura.xml + + container: + needs: coverage + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push Docker image to GHCR + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ghcr.io/${{ env.PACKAGE_NAME }}:latest + ghcr.io/${{ env.PACKAGE_NAME }}:main + ghcr.io/${{ env.PACKAGE_NAME }}:sha-${{ github.sha }} diff --git a/README.md b/README.md index e7e7c8b..e129022 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ docker build -t aspnetcore-app . ```bash docker run -p 9000:9000 aspnetcore-app +``` ## Credits