Skip to content

Commit 1e15726

Browse files
committed
fix: Refactor container image publishing steps to streamline Docker login and tagging process
1 parent 6457cff commit 1e15726

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

.github/workflows/build-and-push-containers.yml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,47 @@ jobs:
2222
with:
2323
dotnet-version: '10.0.x'
2424

25-
# Credentials for .NET container tooling to talk to GHCR
25+
- name: docker login
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
2632
- name: Publish API container image
2733
working-directory: ${{ github.workspace }}
28-
env:
29-
DOTNET_CONTAINER_REGISTRY_USERNAME: ${{ github.actor }}
30-
DOTNET_CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
3134
run: |
3235
dotnet publish src/Playground/Playground.Api/Playground.Api.csproj \
3336
-c Release -r linux-x64 \
3437
-p:PublishProfile=DefaultContainer \
35-
-p:ContainerRegistry=ghcr.io \
36-
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-api \
37-
-p:ContainerImageTags='${{ github.sha }};latest'
38+
-p:ContainerRepository=ghcr.io/${{ github.repository_owner }}/fsh-playground-api \
39+
-p:ContainerImageTags=${{ github.sha }}
3840
3941
- name: Publish Blazor container image
4042
working-directory: ${{ github.workspace }}
41-
env:
42-
DOTNET_CONTAINER_REGISTRY_USERNAME: ${{ github.actor }}
43-
DOTNET_CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
4443
run: |
4544
dotnet publish src/Playground/Playground.Blazor/Playground.Blazor.csproj \
4645
-c Release -r linux-x64 \
4746
-p:PublishProfile=DefaultContainer \
48-
-p:ContainerRegistry=ghcr.io \
49-
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-blazor \
50-
-p:ContainerImageTags='${{ github.sha }};latest'
47+
-p:ContainerRepository=ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor \
48+
-p:ContainerImageTags=${{ github.sha }}
49+
50+
- name: Tag images with latest
51+
working-directory: ${{ github.workspace }}
52+
run: |
53+
docker tag ghcr.io/${{ github.repository_owner }}/fsh-playground-api:${{ github.sha }} \
54+
ghcr.io/${{ github.repository_owner }}/fsh-playground-api:latest
55+
docker tag ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:${{ github.sha }} \
56+
ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:latest
57+
58+
- name: Push API images to GHCR
59+
working-directory: ${{ github.workspace }}
60+
run: |
61+
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:${{ github.sha }}
62+
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:latest
63+
64+
- name: Push Blazor images to GHCR
65+
working-directory: ${{ github.workspace }}
66+
run: |
67+
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:${{ github.sha }}
68+
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:latest

0 commit comments

Comments
 (0)