CI: compute image tags inline (forge has no metadata-action REST API)

d9cc682 · gmorell · 2026-06-25 18:39

1 files +19 -10
Message
{commit_body(@commit)}

Files changed

modified .forgejo/workflows/build.yml
+19 −10
@@ -22,16 +22,23 @@ jobs:
22 22 username: gitgud-actions
23 23 password: ${{ github.token }}
24 24
25 - uses: docker/metadata-action@v5
25 + # docker/metadata-action calls the forge REST API
26 + # (/api/v1/.../commits/<sha>) for commit metadata, but the forge
27 + # doesn't expose that API yet — it 404s and the action dies. Compute
28 + # tags inline instead. Push to the job's OWN repo path
29 + # (<registry>/<owner>/<repo>); the per-job token only grants push
30 + # there. Only runs on master (see `on:`), so sha + latest suffice.
31 + - name: Compute image tags
26 32 id: meta
27 with:
28 # Push to the job's OWN repo path (${{ vars.CI_REGISTRY }}/<owner>/<repo>);
29 # the per-job token only grants push there.
30 images: ${{ vars.CI_REGISTRY }}/${{ github.repository }}
31 tags: |
32 type=sha,format=long
33 type=ref,event=branch
34 type=raw,value=latest,enable={{is_default_branch}}
33 + shell: bash
34 + run: |
35 + IMAGE="${{ vars.CI_REGISTRY }}/${{ github.repository }}"
36 + {
37 + echo "tags<<EOF"
38 + echo "${IMAGE}:sha-${{ github.sha }}"
39 + echo "${IMAGE}:latest"
40 + echo "EOF"
41 + } >> "$GITHUB_OUTPUT"
35 42
36 43 - uses: docker/build-push-action@v6
37 44 with:
@@ -39,6 +46,8 @@ jobs:
39 46 file: ./Dockerfile
40 47 push: true
41 48 tags: ${{ steps.meta.outputs.tags }}
42 labels: ${{ steps.meta.outputs.labels }}
49 + labels: |
50 + org.opencontainers.image.source=https://gg.neiam.co/${{ github.repository }}
51 + org.opencontainers.image.revision=${{ github.sha }}
43 52 cache-from: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache
44 53 cache-to: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache,mode=max

Parents: 28faa73