29
29
30
30
31
31
jobs :
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]
108
36
outputs :
109
37
image : ${{ steps.image.outputs.image }}
110
38
digest : ${{ steps.build-and-push.outputs.digest }}
@@ -150,24 +78,24 @@ jobs:
150
78
151
79
# Build and push Docker image with Buildx (don't push on PR)
152
80
# 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
155
83
uses : docker/build-push-action@v3
156
84
with :
157
85
context : ./ci/gha-runner-image/
158
86
platforms : linux/amd64,linux/arm64
159
87
push : ${{ github.event_name != 'pull_request' }}
160
88
tags : |
161
- ghcr.io/cncf/gha-runner:openeuler
89
+ ghcr.io/cncf/gha-runner:${{ matrix.dockerfile }}
162
90
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.${{ matrix.dockerfile }}
92
+ - name : Sign the published ${{ matrix.dockerfile }} Docker image
165
93
if : ${{ github.event_name != 'pull_request' }}
166
94
env :
167
95
COSIGN_EXPERIMENTAL : " true"
168
96
# Uses the identity token to provision an ephemeral certificate
169
97
# 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 }}
171
99
- name : Output image
172
100
id : image
173
101
run : |
@@ -177,10 +105,11 @@ jobs:
177
105
# form "sha256:<digest>"
178
106
image_name="${REGISTRY}/${IMAGE_NAME}:${{ github.ref_name }}"
179
107
echo "::set-output name=image::$image_name"
108
+
180
109
# Generate SLSA provenance for the image
181
110
# Upload the provenance to ghcr.io
182
111
provenance :
183
- needs : [build]
112
+ needs : [build-images ]
184
113
permissions :
185
114
id-token : write # For signing.
186
115
actions : read # For reading workflow info.
@@ -199,7 +128,7 @@ jobs:
199
128
# branches for required status checks. It should have a unique name among
200
129
# other pre-submits.
201
130
name : verify container provenance
202
- needs : [build, provenance]
131
+ needs : [build-images , provenance]
203
132
permissions :
204
133
packages : read # For reading attestations.
205
134
runs-on : ubuntu-latest
0 commit comments