Skip to content

Commit 6457cff

Browse files
committed
fix: Simplify container image publishing by removing redundant docker login and push steps
1 parent c776c74 commit 6457cff

1 file changed

Lines changed: 9 additions & 29 deletions

File tree

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

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

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-
25+
# Credentials for .NET container tooling to talk to GHCR
3226
- name: Publish API container image
3327
working-directory: ${{ github.workspace }}
28+
env:
29+
DOTNET_CONTAINER_REGISTRY_USERNAME: ${{ github.actor }}
30+
DOTNET_CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
3431
run: |
3532
dotnet publish src/Playground/Playground.Api/Playground.Api.csproj \
3633
-c Release -r linux-x64 \
3734
-p:PublishProfile=DefaultContainer \
3835
-p:ContainerRegistry=ghcr.io \
3936
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-api \
40-
-p:ContainerImageTags=${{ github.sha }}
37+
-p:ContainerImageTags='${{ github.sha }};latest'
4138
4239
- name: Publish Blazor container image
4340
working-directory: ${{ github.workspace }}
41+
env:
42+
DOTNET_CONTAINER_REGISTRY_USERNAME: ${{ github.actor }}
43+
DOTNET_CONTAINER_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
4444
run: |
4545
dotnet publish src/Playground/Playground.Blazor/Playground.Blazor.csproj \
4646
-c Release -r linux-x64 \
4747
-p:PublishProfile=DefaultContainer \
4848
-p:ContainerRegistry=ghcr.io \
4949
-p:ContainerRepository=${{ github.repository_owner }}/fsh-playground-blazor \
50-
-p:ContainerImageTags=${{ github.sha }}
51-
52-
- name: Tag images with latest
53-
working-directory: ${{ github.workspace }}
54-
run: |
55-
docker tag ghcr.io/${{ github.repository_owner }}/fsh-playground-api:${{ github.sha }} \
56-
ghcr.io/${{ github.repository_owner }}/fsh-playground-api:latest
57-
docker tag ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:${{ github.sha }} \
58-
ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:latest
59-
60-
- name: Push API images to GHCR
61-
working-directory: ${{ github.workspace }}
62-
run: |
63-
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:${{ github.sha }}
64-
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-api:latest
65-
66-
- name: Push Blazor images to GHCR
67-
working-directory: ${{ github.workspace }}
68-
run: |
69-
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:${{ github.sha }}
70-
docker push ghcr.io/${{ github.repository_owner }}/fsh-playground-blazor:latest
50+
-p:ContainerImageTags='${{ github.sha }};latest'

0 commit comments

Comments
 (0)