Skip to content

Commit e36c175

Browse files
authored
CI: Enable blocking CI runs on a PR via GitHub label
Note that PRs with blocked runs cannot be merged: this is only useful for draft PRs that will be force-pushed multiple times.
1 parent 12d1dba commit e36c175

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/workflows/CI_master.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,46 @@ concurrency:
4141
cancel-in-progress: true
4242

4343
jobs:
44+
45+
Gate:
46+
runs-on: ubuntu-latest
47+
outputs:
48+
run_ci: ${{ steps.decide.outputs.run_ci }}
49+
steps:
50+
- id: decide
51+
run: |
52+
LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}'
53+
echo "PR labels: $LABELS"
54+
if echo "$LABELS" | grep -qi '"Block CI"\|"block ci"\|"Block-CI"\|"block-ci"'; then
55+
echo "run_ci=false" >> "$GITHUB_OUTPUT"
56+
else
57+
echo "run_ci=true" >> "$GITHUB_OUTPUT"
58+
fi
59+
4460
Prepare:
61+
needs: Gate
62+
if: needs.Gate.outputs.run_ci == 'true'
4563
uses: ./.github/workflows/sub_prepare.yml
4664
with:
4765
artifactBasename: Prepare-${{ github.run_id }}
4866

4967
Pixi:
50-
needs: [Prepare]
68+
needs: [Gate, Prepare]
69+
if: needs.Gate.outputs.run_ci == 'true'
5170
uses: ./.github/workflows/sub_buildPixi.yml
5271
with:
5372
artifactBasename: Pixi-${{ github.run_id }}
5473

5574
# Ubuntu:
56-
# needs: [Prepare]
57-
# if: "!startsWith(github.head_ref, 'refs/heads/backport-')"
75+
# needs: [Gate, Prepare]
76+
# if: "!startsWith(github.head_ref, 'refs/heads/backport-') && needs.Gate.outputs.run_ci == 'true'"
5877
# uses: ./.github/workflows/sub_buildUbuntu.yml
5978
# with:
6079
# artifactBasename: Ubuntu-${{ github.run_id }}
6180

6281
Windows:
82+
needs: [Gate, Prepare]
83+
if: needs.Gate.outputs.run_ci == 'true'
6384
needs: [Prepare]
6485
if: "!startsWith(github.head_ref, 'refs/heads/backport-')"
6586
uses: ./.github/workflows/sub_buildWindows.yml
@@ -81,6 +102,7 @@ jobs:
81102

82103
WrapUp:
83104
needs: [
105+
Gate,
84106
Prepare,
85107
Pixi,
86108
Windows,

0 commit comments

Comments
 (0)