@@ -11,73 +11,213 @@ jobs:
1111 build-and-push-debian-images :
1212 strategy :
1313 matrix :
14+ platform :
15+ - runner : ubuntu-24.04
16+ arch : linux/amd64
17+ - runner : ubuntu-24.04-arm
18+ arch : linux/arm64
1419 branch-name :
1520 - master
16- - rel/auth-4.9.x
21+ # - rel/auth-4.9.x
1722 image :
18- - id : debian-11-pdns-base
19- debian-image-name : python
20- debian-image-tag : 3.11-slim-bullseye
23+ # - id: debian-11-pdns-base
24+ # debian-image-name: python
25+ # debian-image-tag: 3.11-slim-bullseye
2126 - id : debian-12-pdns-base
2227 debian-image-name : debian
2328 debian-image-tag : bookworm-slim
2429 fail-fast : false
25- runs-on : ubuntu-22.04
30+ runs-on : ${{ matrix.platform.runner }}
2631 permissions :
2732 contents : read
2833 packages : write
2934 steps :
30- - uses : actions/checkout@v4
31-
3235 - run : |
3336 echo "image-id-lowercase=ghcr.io/${{ github.repository }}/${{ matrix.image.id }}" | tr '[:upper:]' '[:lower:]' >> "$GITHUB_ENV"
3437 echo "image-tag=$(echo ${{ matrix.branch-name }} | cut -d '/' -f 2)" >> "$GITHUB_ENV"
35-
36- - name : Build image
37- run : |
38- docker build . --file Dockerfile \
39- --tag ${{ env.image-id-lowercase }}:${{ env.image-tag }} \
40- --build-arg DEBIAN_IMAGE_NAME=${{ matrix.image.debian-image-name }} \
41- --build-arg DEBIAN_IMAGE_TAG=${{ matrix.image.debian-image-tag }} \
42- --build-arg REPO_BRANCH=${{ matrix.branch-name }}
43-
38+ echo "image-id-lowercase=ghcr.io/${{ github.repository }}/${{ matrix.image.id }}" | tr '[:upper:]' '[:lower:]'
39+ echo "image-tag=$(echo ${{ matrix.branch-name }} | cut -d '/' -f 2)"
40+ - uses : actions/checkout@v4
41+ with :
42+ persist-credentials : false
43+ - name : Set up Docker Buildx for multi-platform builds
44+ uses : docker/setup-buildx-action@v3
45+ - name : Set up QEMU
46+ uses : docker/setup-qemu-action@v3
47+ # https://github.com/docker/buildx/issues/1335#issuecomment-1343712346
48+ - run : docker ps --all
4449 - name : Login to GitHub Container Registry
4550 if : ${{ github.event_name != 'pull_request' }}
4651 uses : docker/login-action@v3
4752 with :
4853 registry : ghcr.io
4954 username : ${{ github.actor }}
5055 password : ${{ secrets.GITHUB_TOKEN }}
51-
52- - name : Push into Github Container Registry
53- if : ${{ github.event_name != 'pull_request' }}
54- run : |
55- docker push ${{ env.image-id-lowercase }}:${{ env.image-tag }}
56-
57- purge-old-images :
58- name : Purge old PDNS CI images
59- needs : build-and-push-debian-images
60- runs-on : ubuntu-22.04
61- if : ${{ github.event_name != 'pull_request' }}
62- permissions :
63- contents : read
64- packages : write
65- strategy :
66- matrix :
67- image-id :
68- - debian-11-pdns-base
69- - debian-12-pdns-base
70- fail-fast : false
71- steps :
72- - name : Get repository name
56+ - name : Docker image metadata
57+ id : meta
58+ uses : docker/metadata-action@v5
59+ with :
60+ images : ${{ env.image-id-lowercase }}
61+ # tags: ${{ env.image-tag }}
62+ - name : Build and load images
63+ id : build-image
64+ uses : docker/build-push-action@v6
65+ with :
66+ context : .
67+ file : Dockerfile
68+ platforms : ${{ matrix.branch.platforms }}
69+ push : ${{ github.event_name != 'pull_request' && 'true' || 'false' }}
70+ tags : ${{ steps.meta.outputs.tags }}
71+ build-args : |
72+ DEBIAN_IMAGE_NAME=${{ matrix.image.debian-image-name }}
73+ DEBIAN_IMAGE_TAG=${{ matrix.image.debian-image-tag }}
74+ REPO_BRANCH=${{ matrix.branch-name }}
75+ outputs : type=image,push-by-digest=true,name-canonical=true
76+ - name : Export output digest
77+ env :
78+ ARCH : ${{ matrix.platform.arch }}
79+ DIGEST : ${{ steps.build-image.outputs.digest }}
7380 run : |
74- echo "${{ github.repository }}" | awk -F'/' '{print "repo-name="$2}' >> "$GITHUB_ENV"
81+ mkdir -p $RUNNER_TEMP/digests
82+ touch "$RUNNER_TEMP/digests/${DIGEST#sha256:}"
83+ # generate suffix for digest file
84+ echo "PLATFORM_PAIR=${ARCH//\//-}" >> $GITHUB_ENV
85+ - name : Upload digest
86+ uses : actions/upload-artifact@v4
87+ with :
88+ name : digests-${{ env.matrix.image.id }}-${{ env.image-tag }}-${{ env.PLATFORM_PAIR }}
89+ path : ${{ runner.temp }}/digests/*
90+ if-no-files-found : error
91+ retention-days : 1
7592
76- - name : Purge old images keeping the 5 more recent ones
77- # FIXME: move to tag v5 when available.
78- uses : actions/delete-package-versions@v5.0.0
79- with :
80- package-name : ${{ env.repo-name }}/${{ matrix.image-id }}
81- package-type : container
82- min-versions-to-keep : 5
83- delete-only-untagged-versions : true
93+ #
94+ # - name: Build image
95+ # run: |
96+ # docker build . --file Dockerfile \
97+ # --tag ${{ env.image-id-lowercase }}:${{ env.image-tag }} \
98+ # --build-arg DEBIAN_IMAGE_NAME=${{ matrix.image.debian-image-name }} \
99+ # --build-arg DEBIAN_IMAGE_TAG=${{ matrix.image.debian-image-tag }} \
100+ # --build-arg REPO_BRANCH=${{ matrix.branch-name }}
101+ #
102+ # - name: Set up QEMU
103+ # uses: docker/setup-qemu-action@v3
104+ # with:
105+ # platforms: linux/arm64/v8
106+ # - name: Set up Docker Buildx for multi-platform builds
107+ # uses: docker/setup-buildx-action@v3
108+ # with:
109+ # platforms: ${{ inputs.platforms }}
110+ # - name: Login to Docker Hub
111+ # uses: docker/login-action@v3
112+ # with:
113+ # username: ${{ secrets.DOCKERHUB_USERNAME }}
114+ # password: ${{ secrets.DOCKERHUB_TOKEN }}
115+ # - name: Docker image metadata
116+ # id: meta
117+ # uses: docker/metadata-action@v5
118+ # with:
119+ # images: ${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}/${{ inputs.image-name }}
120+ # tags: ${{ inputs.image-tags }}
121+ # - name: Build and load powerdns product images
122+ # id: build-image
123+ # uses: docker/build-push-action@v6
124+ # with:
125+ # context: .
126+ # file: Dockerfile
127+ # platforms: ${{ matrix.branch.platforms }}
128+ # push: ${{ inputs.push }}
129+ # sbom: true
130+ # tags: ${{ steps.meta.outputs.tags }}
131+ # build-args: ${{ inputs.build-args }}
132+ #
133+ # - name: Push into Github Container Registry
134+ # if: ${{ github.event_name != 'pull_request' }}
135+ # run: |
136+ # docker push ${{ env.image-id-lowercase }}:${{ env.image-tag }}
137+ #
138+ # publish-tag:
139+ # name: Generate and publish tag for multi-platform image
140+ # runs-on: ubuntu-24.04
141+ # if: ${{ inputs.push }}
142+ # needs: build
143+ # permissions:
144+ # contents: read
145+ # # This is used to complete the identity challenge
146+ # # with sigstore/fulcio when running outside of PRs.
147+ # id-token: write
148+ # outputs:
149+ # image-digest: ${{ steps.get-image-digest.outputs.image-digest }}
150+ # env:
151+ # IMAGE_NAME: ${{ secrets.DOCKERHUB_ORGANIZATION_NAME }}/${{ inputs.image-name }}
152+ # steps:
153+ # - name: Install cosign
154+ # uses: sigstore/cosign-installer@v3.7.0
155+ # - name: Download digests
156+ # uses: actions/download-artifact@v4
157+ # with:
158+ # path: ${{ runner.temp }}/digests
159+ # pattern: digests-${{ inputs.product }}-*
160+ # merge-multiple: true
161+ # - name: Login to Docker Hub
162+ # if: ${{ inputs.push }}
163+ # uses: docker/login-action@v3
164+ # with:
165+ # username: ${{ secrets.DOCKERHUB_USERNAME }}
166+ # password: ${{ secrets.DOCKERHUB_TOKEN }}
167+ # - name: Set up Docker Buildx
168+ # uses: docker/setup-buildx-action@v3
169+ # - name: Docker meta
170+ # id: meta
171+ # uses: docker/metadata-action@v5
172+ # with:
173+ # images: ${{ env.IMAGE_NAME }}
174+ # tags: ${{ inputs.image-tags }}
175+ # - name: Create manifest list and push
176+ # working-directory: ${{ runner.temp }}/digests
177+ # run: |
178+ # docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
179+ # $(printf $IMAGE_NAME'@sha256:%s ' *)
180+ # - name: Get image digest
181+ # id: get-image-digest
182+ # env:
183+ # TAG: ${{ steps.meta.outputs.version }}
184+ # run: |
185+ # echo "image-digest=$(docker buildx imagetools inspect $IMAGE_NAME:$TAG --format="{{json .Manifest}}" | jq -r .digest)" >> "$GITHUB_OUTPUT"
186+ # - name: Sign product image
187+ # id: sign-image
188+ # env:
189+ # TAG: |
190+ # ${{ env.IMAGE_NAME }}@${{ steps.get-image-digest.outputs.image-digest }}
191+ # # This step uses the identity token to provision an ephemeral certificate
192+ # # against the sigstore community Fulcio instance.
193+ # run: cosign sign --yes ${TAG}
194+ #
195+ #
196+ # purge-old-images:
197+ # name: Purge old PDNS CI images
198+ # needs: build-and-push-debian-images
199+ # runs-on: ubuntu-22.04
200+ # if: ${{ github.event_name != 'pull_request' }}
201+ # permissions:
202+ # contents: read
203+ # packages: write
204+ # strategy:
205+ # matrix:
206+ # image-id:
207+ # - debian-11-pdns-base
208+ # - debian-12-pdns-base
209+ # fail-fast: false
210+ # steps:
211+ # - name: Get repository name
212+ # run: |
213+ # echo "${{ github.repository }}" | awk -F'/' '{print "repo-name="$2}' >> "$GITHUB_ENV"
214+ #
215+ # - name: Purge old images keeping the 5 more recent ones
216+ # # FIXME: move to tag v5 when available.
217+ # uses: actions/delete-package-versions@v5.0.0
218+ # with:
219+ # package-name: ${{ env.repo-name }}/${{ matrix.image-id }}
220+ # package-type: container
221+ # min-versions-to-keep: 5
222+ # delete-only-untagged-versions: true
223+ #
0 commit comments