Skip to content

Commit b40f824

Browse files
Refactor Docker build workflow for consistency
1 parent b819890 commit b40f824

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

.github/workflows/docker-build-backend.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,17 @@ jobs:
3131
include:
3232
- os: ubuntu-latest
3333
platform: linux/amd64
34-
- os: ubuntu-24.04-arm
34+
- os: ubuntu-24.04-arm
3535
platform: linux/arm64
3636

3737
steps:
38-
- name: Checkout
39-
uses: actions/checkout@v6
38+
- uses: actions/checkout@v6
4039

41-
- name: Set up Docker Buildx
42-
uses: docker/setup-buildx-action@v4
40+
- uses: docker/setup-buildx-action@v4
4341
with:
4442
driver: docker-container
4543

46-
- name: Log in to GHCR
47-
uses: docker/login-action@v4
44+
- uses: docker/login-action@v4
4845
with:
4946
registry: ${{ env.REGISTRY }}
5047
username: ${{ github.actor }}
@@ -60,7 +57,6 @@ jobs:
6057
org.opencontainers.image.description=Backend build for ${{ github.repository }} (${{ github.ref_name }})
6158
org.opencontainers.image.source=https://github.com/${{ github.repository }}
6259
org.opencontainers.image.revision=${{ github.sha }}
63-
org.opencontainers.image.licenses=MIT
6460
6561
- name: Build and push by digest
6662
id: build
@@ -74,12 +70,11 @@ jobs:
7470
run: |
7571
mkdir -p /tmp/digests
7672
digest="${{ steps.build.outputs.digest }}"
77-
touch "/tmp/digests/${digest//sha256:/}"
73+
touch "/tmp/digests/${digest#sha256:}"
7874
79-
- name: Upload digest
80-
uses: actions/upload-artifact@v7
75+
- uses: actions/upload-artifact@v7
8176
with:
82-
name: digests-${{ strategy.job-index }}
77+
name: digests-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
8378
path: /tmp/digests/*
8479
if-no-files-found: error
8580
retention-days: 1
@@ -90,15 +85,13 @@ jobs:
9085
if: startsWith(github.ref, 'refs/tags/v')
9186

9287
steps:
93-
- name: Download digests
94-
uses: actions/download-artifact@v8
88+
- uses: actions/download-artifact@v8
9589
with:
9690
path: /tmp/digests
9791
pattern: digests-*
9892
merge-multiple: true
9993

100-
- name: Log in to GHCR
101-
uses: docker/login-action@v4
94+
- uses: docker/login-action@v4
10295
with:
10396
registry: ${{ env.REGISTRY }}
10497
username: ${{ github.actor }}
@@ -114,20 +107,14 @@ jobs:
114107
type=semver,pattern={{version}}
115108
type=raw,value=latest,enable=${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v') }}
116109
117-
- name: Set up Docker Buildx
118-
uses: docker/setup-buildx-action@v4
110+
- uses: docker/setup-buildx-action@v4
119111

120112
- name: Create manifest list and push
121113
working-directory: /tmp/digests
122114
run: |
123-
TAG_ARGS=$(echo "${{ steps.meta.outputs.tags }}" | xargs -I {} echo "-t {}")
115+
TAG_ARGS=$(echo "${{ steps.meta.outputs.tags }}" | sort -u | xargs -I {} echo "-t {}")
124116
DIGEST_ARGS=$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
125117
126118
docker buildx imagetools create \
127119
$TAG_ARGS \
128-
--annotation org.opencontainers.image.title="Backend Image" \
129-
--annotation org.opencontainers.image.description="Backend build for ${{ github.repository }} (${{ github.ref_name }})" \
130-
--annotation org.opencontainers.image.source="https://github.com/${{ github.repository }}" \
131-
--annotation org.opencontainers.image.revision="${{ github.sha }}" \
132-
--annotation org.opencontainers.image.licenses="MIT" \
133120
$DIGEST_ARGS

0 commit comments

Comments
 (0)