2929
3030
3131jobs :
32- build :
33- outputs :
34- image : ${{ steps.image.outputs.image }}
35- digest : ${{ steps.build-and-push.outputs.digest }}
36- runs-on : ubuntu-latest
37- permissions :
38- contents : read
39- packages : write
40- # This is used to complete the identity challenge
41- # with sigstore/fulcio when running outside of PRs.
42- id-token : write
43-
44- steps :
45- - name : Checkout repository
46- uses : actions/checkout@v2
47-
48- # Install the cosign tool except on PR
49- # https://github.com/sigstore/cosign-installer
50- - name : Install cosign
51- if : github.event_name != 'pull_request'
52- uses : sigstore/cosign-installer@main
53- - name : Set up QEMU
54- uses : docker/setup-qemu-action@v3
55- - name : Set up Docker Buildx
56- uses : docker/setup-buildx-action@v3
57-
58- # Login against a Docker registry except on PR
59- # https://github.com/docker/login-action
60- - name : Log into registry ${{ env.REGISTRY }}
61- if : github.event_name != 'pull_request'
62- uses : docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
63- with :
64- registry : ${{ env.REGISTRY }}
65- username : ${{ github.actor }}
66- password : ${{ secrets.GITHUB_TOKEN }}
67-
68- # Extract metadata (tags, labels) for Docker
69- # https://github.com/docker/metadata-action
70- - name : Extract Docker metadata
71- id : meta
72- uses : docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
73- with :
74- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
75-
76- # Build and push Docker image with Buildx (don't push on PR)
77- # https://github.com/docker/build-push-action
78- - name : Build and push Docker image
79- id : build-and-push
80- uses : docker/build-push-action@v3
81- with :
82- context : ./ci/gha-runner-image/
83- platforms : linux/amd64,linux/arm64
84- push : ${{ github.event_name != 'pull_request' }}
85- tags : ${{ steps.meta.outputs.tags }}
86- labels : ${{ steps.meta.outputs.labels }}
87- # Build and push Docker image with Buildx (don't push on PR)
88- # https://github.com/docker/build-push-action
89- - name : Sign the published Docker image
90- if : ${{ github.event_name != 'pull_request' }}
91- env :
92- COSIGN_EXPERIMENTAL : " true"
93- # uses the identity token to provision an ephemeral certificate
94- # against the sigstore community Fulcio instance.
95- run : |
96- cosign sign --yes \
97- ${{env.REGISTRY}}/${{env.IMAGE_NAME}}@${{steps.build-and-push.outputs.digest}}
98- - name : Output image
99- id : image
100- run : |
101- # NOTE: We need to use the image and digest in order to make sure
102- # that the image we attest has not been modified.
103- # NOTE: The digest output from docker/build-push-action is of the
104- # form "sha256:<digest>"
105- image_name="${REGISTRY}/${IMAGE_NAME}:${{ github.ref_name }}"
106- echo "::set-output name=image::$image_name"
107- build-openeuler :
32+ build-images :
33+ strategy :
34+ matrix :
35+ dockerfile : [ubuntu2204, ubuntu2404]
10836 outputs :
10937 image : ${{ steps.image.outputs.image }}
11038 digest : ${{ steps.build-and-push.outputs.digest }}
@@ -150,24 +78,24 @@ jobs:
15078
15179 # Build and push Docker image with Buildx (don't push on PR)
15280 # https://github.com/docker/build-push-action
153- - name : Build and push OpenEuler Docker image
154- id : build-and-push-openeuler
81+ - name : Build and push ${{ matrix.dockerfile }} Docker image
82+ id : build-and-push
15583 uses : docker/build-push-action@v3
15684 with :
15785 context : ./ci/gha-runner-image/
15886 platforms : linux/amd64,linux/arm64
15987 push : ${{ github.event_name != 'pull_request' }}
16088 tags : |
161- ghcr.io/cncf/gha-runner:openeuler
89+ ghcr.io/cncf/gha-runner:${{ matrix.dockerfile }}
16290 labels : ${{ steps.meta.outputs.labels }}
163- file : ./ci/gha-runner-image/Dockerfile.openeuler
164- - name : Sign the published OpenEuler Docker image
91+ file : ./ci/gha-runner-image/Dockerfile.22.04
92+ - name : Sign the published ${{ matrix.dockerfile }} Docker image
16593 if : ${{ github.event_name != 'pull_request' }}
16694 env :
16795 COSIGN_EXPERIMENTAL : " true"
16896 # Uses the identity token to provision an ephemeral certificate
16997 # against the sigstore community Fulcio instance.
170- run : cosign sign -y ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:openeuler
98+ run : cosign sign -y ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.dockerfile }}
17199 - name : Output image
172100 id : image
173101 run : |
@@ -177,10 +105,11 @@ jobs:
177105 # form "sha256:<digest>"
178106 image_name="${REGISTRY}/${IMAGE_NAME}:${{ github.ref_name }}"
179107 echo "::set-output name=image::$image_name"
108+
180109 # Generate SLSA provenance for the image
181110 # Upload the provenance to ghcr.io
182111 provenance :
183- needs : [build]
112+ needs : [build-images ]
184113 permissions :
185114 id-token : write # For signing.
186115 actions : read # For reading workflow info.
@@ -199,7 +128,7 @@ jobs:
199128 # branches for required status checks. It should have a unique name among
200129 # other pre-submits.
201130 name : verify container provenance
202- needs : [build, provenance]
131+ needs : [build-images , provenance]
203132 permissions :
204133 packages : read # For reading attestations.
205134 runs-on : ubuntu-latest
0 commit comments