Skip to content

Commit fdd8d53

Browse files
authored
Publish containers tagged with version created by uci releaser (#794)
This repository started using unified CI (uci) a while back to make tagged releases. This release mechanism is triggered by editing the `version.json` which in turn triggers a CI workflow to make a tagged release along with ghithub release etc. The issue with this approach is that because the tag is created by CI it does not trigger other CI jobs that listen to `tags: ['v*']` events. Therefore, since the switch we have only been publishing containers tagged with `main`. The changes here resolve this issue by triggering the GHCR publish workflow whenever releaser wrokflow succeeds. It then fishes out the ref produced by the releaser workflow to use as tagging. This will then give us containers tagged by whatever release we make using uci releaser workflow. Additionally, it adds `type=sha,format=long` tagging to containers for easier debugging and deployment of an explicit commit to `main`.
1 parent 28ccfd8 commit fdd8d53

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

.github/workflows/publish-ghcr.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,38 @@ on:
66
- 'main'
77
tags:
88
- 'v*'
9+
workflow_run:
10+
workflows: [ Releaser ]
11+
types:
12+
- completed
913
pull_request:
1014

1115
jobs:
16+
prepare-checkout:
17+
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
18+
name: Prepare ref
19+
runs-on: ubuntu-latest
20+
outputs:
21+
ref: ${{ github.event_name != 'workflow_run' && github.ref || steps.releaser.outputs.version }}
22+
steps:
23+
- name: Get version tag from releaser
24+
id: releaser
25+
if: github.event_name == 'workflow_run'
26+
uses: ipdxco/unified-github-workflows/.github/actions/[email protected]
27+
with:
28+
artifacts-url: ${{ github.event.workflow_run.artifacts_url }}
1229
publish:
13-
name: publish
30+
name: Publish
31+
needs: [ prepare-checkout ]
1432
runs-on: ubuntu-latest
1533
permissions:
1634
contents: read
1735
packages: write
1836
steps:
1937
- name: Checkout
2038
uses: actions/checkout@v4
39+
with:
40+
ref: ${{ needs.prepare-checkout.outputs.ref }}
2141
- name: Set up Docker Buildx
2242
uses: docker/setup-buildx-action@v3
2343
- name: Log in to the Container registry
@@ -34,7 +54,8 @@ jobs:
3454
tags: |
3555
type=semver,pattern={{raw}}
3656
type=ref,event=branch
37-
type=raw,value=${{ github.ref }}
57+
type=sha,format=long
58+
type=raw,value=${{ needs.prepare-checkout.outputs.ref }}
3859
- name: Build and push Docker image
3960
uses: docker/build-push-action@v6
4061
with:

0 commit comments

Comments
 (0)