Skip to content

Commit 0fd5dca

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 0fd5dca

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,29 @@ 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+
echo is-single-arch-build >> ${GITHUB_OUTPUT}
28+
curl --silent --location \
29+
--header "Accept: application/vnd.github+json" \
30+
--header "Authorization: Bearer ${GITHUB_TOKEN}" \
31+
--header "X-GitHub-Api-Version: 2022-11-28" \
32+
https://api.github.com/repos/ceph/ceph-csi/pulls/5969 | \
33+
jq '[.labels[].name]|any(. == "ci/skip/multi-arch-build")' \
34+
>> ${GITHUB_OUTPUT}
2235
# yamllint disable-line rule:line-length
2336
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2437
- name: multi-arch-build
2538
# yamllint disable-line rule:line-length
26-
if: ${{ ! contains(github.event.pull_request.labels.*.name, 'ci/skip/multi-arch-build') }}
39+
if: steps.detect-single-build.output.is-single-arch-build != "true"
2740
# podman cannot pull images with both tag and digest
2841
# https://github.com/containers/buildah/issues/1407
2942
# use docker to build images
3043
run: CONTAINER_CMD=docker ./scripts/build-multi-arch-image.sh
3144
- name: single-arch-build
3245
# yamllint disable-line rule:line-length
33-
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/skip/multi-arch-build') }}
46+
if: steps.detect-single-build.output.is-single-arch-build == "true"
3447
run: make containerized-build

0 commit comments

Comments
 (0)