Skip to content

Commit a37b92e

Browse files
authored
Merge pull request #231 from nanotaboada/feature/ghcr
feat(ci): update workflow to build and publish Docker image to GHCR
2 parents 9d0b531 + 2a43eca commit a37b92e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

.github/workflows/dotnet.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414

1515
env:
1616
DOTNET_VERSION: 8.0.x
17+
PACKAGE_NAME: nanotaboada/dotnet-samples-aspnetcore-webapi
1718

1819
jobs:
1920
build:
@@ -104,3 +105,35 @@ jobs:
104105
with:
105106
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
106107
coverage-reports: cobertura.xml
108+
109+
container:
110+
needs: coverage
111+
runs-on: ubuntu-latest
112+
113+
permissions:
114+
contents: read
115+
packages: write
116+
117+
steps:
118+
- name: Checkout repository
119+
uses: actions/checkout@v4
120+
121+
- name: Log in to GitHub Container Registry
122+
uses: docker/login-action@v3
123+
with:
124+
registry: ghcr.io
125+
username: ${{ github.actor }}
126+
password: ${{ secrets.GITHUB_TOKEN }}
127+
128+
- name: Set up Docker Buildx
129+
uses: docker/setup-buildx-action@v3
130+
131+
- name: Build and push Docker image to GHCR
132+
uses: docker/build-push-action@v5
133+
with:
134+
context: .
135+
push: true
136+
tags: |
137+
ghcr.io/${{ env.PACKAGE_NAME }}:latest
138+
ghcr.io/${{ env.PACKAGE_NAME }}:main
139+
ghcr.io/${{ env.PACKAGE_NAME }}:sha-${{ github.sha }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ docker build -t aspnetcore-app .
4848

4949
```bash
5050
docker run -p 9000:9000 aspnetcore-app
51+
```
5152

5253
## Credits
5354

0 commit comments

Comments
 (0)