Skip to content

Commit d21cbbb

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 d21cbbb

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,30 @@ jobs:
1919
name: multi-arch-build
2020
runs-on: ubuntu-latest
2121
steps:
22+
- name: detect single-arch-build
23+
id: detect-single-build
24+
# wait 1 minute because setting labels may be delayed
25+
run: |
26+
sleep 1m
27+
PR=${{ github.event.pull_request.number }}
28+
( echo -n 'is-single-arch-build='
29+
curl --silent --location \
30+
--header "Accept: application/vnd.github+json" \
31+
--header "Authorization: Bearer ${GITHUB_TOKEN}" \
32+
--header "X-GitHub-Api-Version: 2022-11-28" \
33+
"https://api.github.com/repos/ceph/ceph-csi/pulls/${PR}" | \
34+
jq '[.labels[].name]|any(. == "ci/skip/multi-arch-build")' \
35+
) >> ${GITHUB_OUTPUT}
2236
# yamllint disable-line rule:line-length
2337
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2438
- name: multi-arch-build
2539
# yamllint disable-line rule:line-length
26-
if: ${{ ! contains(github.event.pull_request.labels.*.name, 'ci/skip/multi-arch-build') }}
40+
if: steps.detect-single-build.output.is-single-arch-build != "true"
2741
# podman cannot pull images with both tag and digest
2842
# https://github.com/containers/buildah/issues/1407
2943
# use docker to build images
3044
run: CONTAINER_CMD=docker ./scripts/build-multi-arch-image.sh
3145
- name: single-arch-build
3246
# yamllint disable-line rule:line-length
33-
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/skip/multi-arch-build') }}
47+
if: steps.detect-single-build.output.is-single-arch-build == "true"
3448
run: make containerized-build

0 commit comments

Comments
 (0)