Skip to content

Commit 3454814

Browse files
committed
ci: delay checking ci/skip/multi-arch-build label
When a GitHub Event is created, the labels of the PR are set to the current values. Mergify will only set the labels, or copy the labels to the PR once the PR is created. That means the initial GitHub Event does not have the right labels set yet. In order to really skip the multi-arch-build, and run single-arch-build instead, the label needs to be checked from the PR, instead of compared from the labels in the GitHub Event. Signed-off-by: Niels de Vos <[email protected]>
1 parent 48c9c89 commit 3454814

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

.github/workflows/build-multi-stage.yaml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,37 @@ jobs:
1919
name: multi-arch-build
2020
runs-on: ubuntu-latest
2121
steps:
22+
- name: delay a minute to have labels added
23+
run: sleep 1m
24+
- name: detect single-arch-build
25+
# yamllint disable-line rule:line-length
26+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
27+
id: detect-single-arch-build
28+
with:
29+
script: |
30+
const pr = github.rest.pulls.get({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
pull_number: github.event.pull_request.number,
34+
})
35+
36+
for (const l of pr.labels) {
37+
if (l === 'ci/skip/multi-arch-build') {
38+
return true
39+
}
40+
}
41+
42+
return false
43+
result-encoding: bool
44+
2245
# yamllint disable-line rule:line-length
2346
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2447
- name: multi-arch-build
25-
# yamllint disable-line rule:line-length
26-
if: ${{ ! contains(github.event.pull_request.labels.*.name, 'ci/skip/multi-arch-build') }}
48+
if: !steps.detect-single-arch-build.outputs.is-single-arch-build
2749
# podman cannot pull images with both tag and digest
2850
# https://github.com/containers/buildah/issues/1407
2951
# use docker to build images
3052
run: CONTAINER_CMD=docker ./scripts/build-multi-arch-image.sh
3153
- name: single-arch-build
32-
# yamllint disable-line rule:line-length
33-
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/skip/multi-arch-build') }}
54+
if: steps.detect-single-arch-build.outputs.is-single-arch-build
3455
run: make containerized-build

0 commit comments

Comments
 (0)