Skip to content

Commit ae648d5

Browse files
committed
chore(ci): Require ready-to-merge label to run all checks
1 parent 4a17c8f commit ae648d5

4 files changed

Lines changed: 68 additions & 8 deletions

File tree

.github/workflows/e2e-v2.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- v5
88
- release/**
99
pull_request:
10+
types: [opened, synchronize, reopened, labeled]
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.ref }}
@@ -24,9 +25,15 @@ jobs:
2425
auth_token_check:
2526
uses: ./.github/workflows/skip-ci-noauth.yml
2627
secrets: inherit
28+
ready-to-merge-gate:
29+
name: Ready-to-merge gate
30+
uses: ./.github/workflows/ready-to-merge-workflow.yml
31+
with:
32+
is-pr: ${{ github.event_name == 'pull_request' }}
33+
labels: ${{ toJson(github.event.pull_request.labels) }}
2734
metrics:
2835
runs-on: ${{ matrix.runs-on }}
29-
needs: [diff_check, auth_token_check]
36+
needs: [ready-to-merge-gate,diff_check, auth_token_check]
3037
if: ${{ needs.diff_check.outputs.skip_ci != 'true' && needs.auth_token_check.outputs.skip_ci != 'true' && !startsWith(github.ref, 'refs/heads/release/') }}
3138
env:
3239
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
@@ -158,7 +165,7 @@ jobs:
158165
react-native-build:
159166
name: Build RN ${{ matrix.rn-version }} ${{ matrix.rn-architecture }} ${{ matrix.engine }} ${{ matrix.platform }} ${{ matrix.build-type }} ${{ matrix.ios-use-frameworks }}
160167
runs-on: ${{ matrix.runs-on }}
161-
needs: [diff_check, auth_token_check]
168+
needs: [ready-to-merge-gate,diff_check, auth_token_check]
162169
if: ${{ needs.diff_check.outputs.skip_ci != 'true' && needs.auth_token_check.outputs.skip_ci != 'true' && !startsWith(github.ref, 'refs/heads/release/') }}
163170
env:
164171
RN_VERSION: ${{ matrix.rn-version }}
@@ -294,7 +301,7 @@ jobs:
294301
name:
295302
Test RN ${{ matrix.rn-version }} ${{ matrix.rn-architecture }} ${{ matrix.engine }} ${{ matrix.platform }} ${{
296303
matrix.build-type }} ${{ matrix.ios-use-frameworks }}
297-
needs: [react-native-build, diff_check]
304+
needs: [ready-to-merge-gate, react-native-build, diff_check]
298305
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
299306

300307
runs-on: ${{ matrix.runs-on }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Ready to Merge Workflow
2+
on:
3+
workflow_call:
4+
inputs:
5+
labels:
6+
description: The GitHub event's labels
7+
required: true
8+
type: string
9+
is-pr:
10+
description: Whether the workflow is running on a PR
11+
required: true
12+
type: boolean
13+
14+
jobs:
15+
ready-to-merge-gate:
16+
name: 'Missing "ready-to-merge" label'
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check for exact 'ready-to-merge' label
20+
if: ${{ inputs.is-pr }}
21+
id: check-label
22+
run: |
23+
# Use jq to check for exact label match (avoids substring matching issues with contains())
24+
if echo '${{ inputs.labels }}' | jq -e '.[] | select(.name == "ready-to-merge")' > /dev/null; then
25+
echo "label_found=true" >> $GITHUB_OUTPUT
26+
else
27+
echo "label_found=false" >> $GITHUB_OUTPUT
28+
fi
29+
# Since Github also accepts `skipped` results for Required Workflows, we need
30+
# to fail the job to ensure that the downstream jobs don't just skip.
31+
- name: Fail until the 'ready-to-merge' label is present
32+
if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'false' }}
33+
run: |
34+
echo "Add the 'ready-to-merge' label to run CI."
35+
exit 1
36+
- name: Gate passed
37+
if: ${{ inputs.is-pr && steps.check-label.outputs.label_found == 'true' }}
38+
run: echo "Label present. Proceeding with CI."
39+
- name: Gate passed
40+
if: ${{ !inputs.is-pr }}
41+
run: echo "Not a PR. Proceeding with CI."

.github/workflows/sample-application-expo.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- v5
88
pull_request:
9+
types: [opened, synchronize, reopened, labeled]
910

1011
concurrency:
1112
group: ${{ github.workflow }}-${{ github.ref }}
@@ -18,11 +19,16 @@ env:
1819
jobs:
1920
diff_check:
2021
uses: ./.github/workflows/skip-ci.yml
21-
22+
ready-to-merge-gate:
23+
name: Ready-to-merge gate
24+
uses: ./.github/workflows/ready-to-merge-workflow.yml
25+
with:
26+
is-pr: ${{ github.event_name == 'pull_request' }}
27+
labels: ${{ toJson(github.event.pull_request.labels) }}
2228
build:
2329
name: Build ${{ matrix.platform }} ${{ matrix.build-type }} ${{ matrix.ios-use-frameworks}}
2430
runs-on: ${{ matrix.runs-on }}
25-
needs: [diff_check]
31+
needs: [ready-to-merge-gate, diff_check]
2632
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
2733
env:
2834
SENTRY_DISABLE_AUTO_UPLOAD: 'true'

.github/workflows/sample-application.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- v5
88
pull_request:
9+
types: [opened, synchronize, reopened, labeled]
910

1011
concurrency:
1112
group: ${{ github.workflow }}-${{ github.ref }}
@@ -25,11 +26,16 @@ env:
2526
jobs:
2627
diff_check:
2728
uses: ./.github/workflows/skip-ci.yml
28-
29+
ready-to-merge-gate:
30+
name: Ready-to-merge gate
31+
uses: ./.github/workflows/ready-to-merge-workflow.yml
32+
with:
33+
is-pr: ${{ github.event_name == 'pull_request' }}
34+
labels: ${{ toJson(github.event.pull_request.labels) }}
2935
build:
3036
name: Build ${{ matrix.rn-architecture }} ${{ matrix.platform }} ${{ matrix.build-type }} ${{ matrix.ios-use-frameworks}}
3137
runs-on: ${{ matrix.runs-on }}
32-
needs: [diff_check]
38+
needs: [ready-to-merge-gate, diff_check]
3339
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
3440
env:
3541
SENTRY_DISABLE_AUTO_UPLOAD: 'true'
@@ -215,7 +221,7 @@ jobs:
215221
test:
216222
name: Test ${{ matrix.platform }} ${{ matrix.build-type }} REV2
217223
runs-on: ${{ matrix.runs-on }}
218-
needs: [diff_check, build]
224+
needs: [ready-to-merge-gate, diff_check, build]
219225
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
220226
strategy:
221227
# we want that the matrix keeps running, default is to cancel them if it fails.

0 commit comments

Comments
 (0)