Skip to content

Commit aeb226f

Browse files
committed
Fix impage publication to ghcr
Change the trigger logic to publish images to ghcr whenever releaser unified CI succeeds. Combine the build and release jobs into one with conditional push.
1 parent 03785ff commit aeb226f

File tree

3 files changed

+47
-82
lines changed

3 files changed

+47
-82
lines changed

.github/workflows/docker-image.yml

-18
This file was deleted.

.github/workflows/docker-publish.yml

+46-63
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,66 @@
1-
name: Docker-Publish
1+
name: Container
22

33
on:
44
push:
5-
# Publish semver tags as releases.
6-
tags: [ 'v*.*.*' ]
7-
8-
env:
9-
# Use docker.io for Docker Hub if empty
10-
REGISTRY: ghcr.io
11-
# github.repository as <account>/<repo>
12-
IMAGE_NAME: ${{ github.repository }}
13-
5+
branches:
6+
- 'main'
7+
tags:
8+
- 'v*'
9+
workflow_run:
10+
workflows: [ Releaser ]
11+
types:
12+
- completed
13+
pull_request:
1414

1515
jobs:
16-
build:
17-
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 Ref from releaser
24+
id: releaser
25+
if: github.event_name == 'workflow_run'
26+
uses: pl-strflt/uci/.github/actions/[email protected]
27+
with:
28+
artifacts-url: ${{ github.event.workflow_run.artifacts_url }}
29+
publish:
30+
name: Publish
31+
needs: [ prepare-checkout ]
1832
runs-on: ubuntu-latest
1933
permissions:
2034
contents: read
2135
packages: write
22-
# This is used to complete the identity challenge
23-
# with sigstore/fulcio when running outside of PRs.
24-
id-token: write
25-
2636
steps:
27-
- name: Checkout repository
28-
uses: actions/checkout@v4
29-
30-
# Install the cosign tool except on PR
31-
# https://github.com/sigstore/cosign-installer
32-
- name: Install cosign
33-
if: github.event_name != 'pull_request'
34-
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19
37+
- name: Checkout
38+
uses: actions/checkout@v3
3539
with:
36-
cosign-release: 'v1.9.0'
37-
38-
39-
# Workaround: https://github.com/docker/build-push-action/issues/461
40-
- name: Setup Docker buildx
41-
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
42-
43-
# Login against a Docker registry except on PR
44-
# https://github.com/docker/login-action
45-
- name: Log into registry ${{ env.REGISTRY }}
46-
if: github.event_name != 'pull_request'
47-
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
40+
ref: ${{ needs.prepare-checkout.outputs.ref }}
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@v2
43+
- name: Log in to the Container registry
44+
uses: docker/login-action@v2
4845
with:
49-
registry: ${{ env.REGISTRY }}
46+
registry: ghcr.io
5047
username: ${{ github.actor }}
51-
password: ${{ secrets.GITHUB_TOKEN }}
52-
53-
# Extract metadata (tags, labels) for Docker
54-
# https://github.com/docker/metadata-action
55-
- name: Extract Docker metadata
48+
password: ${{ github.token }}
49+
- name: Extract metadata
5650
id: meta
57-
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934
51+
uses: docker/metadata-action@v4
5852
with:
59-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60-
61-
# Build and push Docker image with Buildx (don't push on PR)
62-
# https://github.com/docker/build-push-action
53+
images: ghcr.io/${{ github.repository }}
54+
tags: |
55+
type=semver,pattern={{raw}}
56+
type=ref,event=branch
57+
type=raw,value=${{ needs.prepare-checkout.outputs.ref }}
6358
- name: Build and push Docker image
64-
id: build-and-push
65-
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
59+
uses: docker/build-push-action@v4
6660
with:
6761
context: .
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max
6864
push: ${{ github.event_name != 'pull_request' }}
6965
tags: ${{ steps.meta.outputs.tags }}
70-
labels: ${{ steps.meta.outputs.labels }}
71-
72-
# Sign the resulting Docker image digest except on PRs.
73-
# This will only write to the public Rekor transparency log when the Docker
74-
# repository is public to avoid leaking data. If you would like to publish
75-
# transparency data even for private images, pass --force to cosign below.
76-
# https://github.com/sigstore/cosign
77-
- name: Sign the published Docker image
78-
if: ${{ github.event_name != 'pull_request' }}
79-
env:
80-
COSIGN_EXPERIMENTAL: "true"
81-
# This step uses the identity token to provision an ephemeral certificate
82-
# against the sigstore community Fulcio instance.
83-
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
66+
labels: ${{ steps.meta.outputs.labels }}

version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v0.1.2"
2+
"version": "v0.1.3"
33
}

0 commit comments

Comments
 (0)