Skip to content

Commit d9a39bb

Browse files
Enhance Docker workflow with metadata and manifest updates
Added metadata extraction and improved manifest creation for Docker images.
1 parent 06bf8d8 commit d9a39bb

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ on:
1313
- '.github/workflows/**'
1414
workflow_dispatch:
1515
release:
16-
types: [published]
16+
types: [published]
1717

1818
permissions:
19-
contents: read
20-
packages: write
19+
contents: read
20+
packages: write
2121

2222
env:
2323
REGISTRY: ghcr.io
@@ -33,7 +33,6 @@ jobs:
3333
platform: linux/amd64
3434
- os: ubuntu-24.04-arm
3535
platform: linux/arm64
36-
3736

3837
steps:
3938
- name: Checkout
@@ -51,13 +50,26 @@ jobs:
5150
username: ${{ github.actor }}
5251
password: ${{ secrets.GITHUB_TOKEN }}
5352

53+
- name: Extract metadata (Digests Only)
54+
id: meta
55+
uses: docker/metadata-action@v6
56+
with:
57+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
58+
annotations: |
59+
org.opencontainers.image.title=Backend Image
60+
org.opencontainers.image.description=Backend build for ${{ github.repository }} (${{ github.ref_name }})
61+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
62+
org.opencontainers.image.revision=${{ github.sha }}
63+
org.opencontainers.image.licenses=MIT
64+
5465
- name: Build and push by digest
5566
id: build
5667
uses: docker/build-push-action@v7
5768
with:
5869
context: ./src/backend
5970
platforms: ${{ matrix.platform }}
6071
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
72+
annotations: ${{ steps.meta.outputs.annotations }}
6173

6274
- name: Export digest
6375
run: |
@@ -103,18 +115,21 @@ jobs:
103115
type=semver,pattern={{version}}
104116
type=raw,value=latest,enable=${{ github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v') }}
105117
106-
107118
- name: Set up Docker Buildx
108119
uses: docker/setup-buildx-action@v4
109120

110121
- name: Create manifest list and push
111122
working-directory: /tmp/digests
112123
run: |
113-
# Create an array of tags prefixed with -t
114124
TAG_ARGS=$(echo "${{ steps.meta.outputs.tags }}" | xargs -I {} echo "-t {}")
115-
116-
# Create an array of digests prefixed with the image name
117125
DIGEST_ARGS=$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
118-
119-
# Execute the command
120-
docker buildx imagetools create $TAG_ARGS $DIGEST_ARGS
126+
127+
docker buildx imagetools create \
128+
$TAG_ARGS \
129+
--annotation org.opencontainers.image.title="Backend Image" \
130+
--annotation org.opencontainers.image.description="Backend build for ${{ github.repository }} (${{
131+
github.ref_name }})" \
132+
--annotation org.opencontainers.image.source="https://github.com/${{ github.repository }}" \
133+
--annotation org.opencontainers.image.revision="${{ github.sha }}" \
134+
--annotation org.opencontainers.image.licenses="MIT" \
135+
$DIGEST_ARGS

0 commit comments

Comments
 (0)