Skip to content

Commit ef9010a

Browse files
committed
fix cicd workflow
1 parent 887183c commit ef9010a

File tree

1 file changed

+71
-10
lines changed

1 file changed

+71
-10
lines changed

.github/workflows/cicd.yml

+71-10
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,24 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
os: [ubuntu-24.04, ubuntu-24.04-arm]
25+
os: [{name: ubuntu-24.04, arch: amd64}, {name: ubuntu-24.04-arm, arch: arm64}]
2626

2727
permissions:
2828
contents: read
2929
packages: write
30-
attestations: write
3130
id-token: write
3231

33-
runs-on: ${{ matrix.os }}
32+
runs-on: ${{ matrix.os.name }}
3433
needs: [ tests ]
3534
steps:
3635
- name: Checkout repository
3736
uses: actions/checkout@v4
3837

38+
- name: Prepare
39+
run: |
40+
platform=linux/${{ matrix.os.arch }}
41+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
42+
3943
- name: Log in to the Container registry
4044
uses: docker/login-action@v3
4145
with:
@@ -53,18 +57,75 @@ jobs:
5357
uses: docker/setup-buildx-action@v3
5458

5559
- name: Build and push Docker image
56-
id: push
60+
id: build
5761
uses: docker/build-push-action@v6
5862
with:
5963
context: .
6064
push: true
6165
provenance: false
62-
tags: ${{ steps.meta.outputs.tags }}
66+
platforms: linux/${{ matrix.os.arch }}
67+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6368
labels: ${{ steps.meta.outputs.labels }}
69+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
70+
71+
- name: Export digest
72+
run: |
73+
mkdir -p ${{ runner.temp }}/digests
74+
digest="${{ steps.build.outputs.digest }}"
75+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
76+
ls -lah ${{ runner.temp }}/digests/
77+
78+
- name: Upload digest
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: digests-${{ env.PLATFORM_PAIR }}
82+
path: ${{ runner.temp }}/digests/*
83+
if-no-files-found: error
84+
retention-days: 1
85+
86+
manifests:
87+
permissions:
88+
contents: read
89+
packages: write
90+
id-token: write
91+
92+
runs-on: ubuntu-latest
93+
needs: [ docker ]
94+
steps:
95+
- name: Download digests
96+
uses: actions/download-artifact@v4
97+
with:
98+
path: ${{ runner.temp }}/digests
99+
pattern: digests-*
100+
merge-multiple: true
101+
102+
- name: Log in to the Container registry
103+
uses: docker/login-action@v3
104+
with:
105+
registry: ${{ env.REGISTRY }}
106+
username: ${{ github.actor }}
107+
password: ${{ secrets.GITHUB_TOKEN }}
108+
109+
- name: Set up Docker Buildx
110+
uses: docker/setup-buildx-action@v3
64111

65-
- name: Generate artifact attestation
66-
uses: actions/attest-build-provenance@v2
112+
- name: Docker meta
113+
id: meta
114+
uses: docker/metadata-action@v5
67115
with:
68-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
69-
subject-digest: ${{ steps.push.outputs.digest }}
70-
push-to-registry: true
116+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
117+
tags: |
118+
type=ref,event=branch
119+
type=ref,event=pr
120+
type=semver,pattern={{version}}
121+
type=semver,pattern={{major}}.{{minor}}
122+
123+
- name: Create manifest list and push
124+
working-directory: ${{ runner.temp }}/digests
125+
run: |
126+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
127+
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
128+
129+
- name: Inspect image
130+
run: |
131+
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)