@@ -2,7 +2,8 @@ name: Create and publish a container image
22
33on :
44 push :
5- branches : main
5+ branches :
6+ - main
67 schedule :
78 - cron : " 2 02 4 * *"
89
@@ -19,41 +20,43 @@ jobs:
1920 attestations : write
2021 contents : read
2122 packages : write
23+ artifact-metadata : write
24+
2225 steps :
2326 - name : Checkout
24- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
25-
26- - name : Set up QEMU
27- uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # ratchet:docker/setup-qemu-action@v3
27+ uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # ratchet:actions/checkout@v6
2828
29- - name : Set up Docker Buildx
30- uses : docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # ratchet:docker/setup-buildx-action@v3
31-
32- - name : Log in to the container registry
33- uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # ratchet:docker/login-action@v3
34- with :
35- registry : ${{ env.REGISTRY }}
36- username : ${{ github.actor }}
37- password : ${{ secrets.GITHUB_TOKEN }}
29+ - name : Authenticate to GHCR
30+ env :
31+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32+ run : |
33+ set -euo pipefail
34+ echo "${GITHUB_TOKEN}" | buildah login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin --compat-auth-file=/home/runner/.docker/config.json
3835
39- - name : Extract metadata for Docker
40- id : meta
41- uses : docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # ratchet:docker/metadata-action@v5
42- with :
43- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44-
45- - name : Build and push Docker image
36+ - name : Build and push image
4637 id : build-push
47- uses : docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # ratchet:docker/build-push-action@v6
48- with :
49- platforms : linux/amd64,linux/arm64
50- push : true
51- tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
52- labels : ${{ steps.meta.outputs.labels }}
53- annotations : ${{ steps.meta.outputs.annotations }}
38+ run : |
39+ set -euo pipefail
40+
41+ IMAGE="${REGISTRY}/${IMAGE_NAME}:latest"
42+ CREATED="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
43+
44+ buildah build \
45+ --jobs 2 \
46+ --platform=linux/arm64,linux/amd64 \
47+ --manifest "${IMAGE}" \
48+ --label org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}" \
49+ --label org.opencontainers.image.revision="${GITHUB_SHA}" \
50+ --label org.opencontainers.image.created="${CREATED}" \
51+ .
52+
53+ buildah push "${IMAGE}"
54+ buildah manifest push --all "${IMAGE}" "docker://${IMAGE}"
55+ DIGEST="$(skopeo inspect docker://${IMAGE} | jq -r .Digest)"
56+ echo "digest=${DIGEST}" >> "$GITHUB_OUTPUT"
5457
5558 - name : Generate artifact attestation
56- uses : actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # ratchet:actions/attest-build-provenance@v2
59+ uses : actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # ratchet:actions/attest-build-provenance@v2
5760 with :
5861 subject-name : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5962 subject-digest : ${{ steps.build-push.outputs.digest }}
0 commit comments