Skip to content

Commit afe2566

Browse files
committed
Fix(ci): restrict integration tests to trusted contributors or safe-to-test label
Gate the get-sha job in tests-integration.yml so CI runs automatically only for contributors with explicit repository write access (OWNER or COLLABORATOR). All others require a maintainer to add the "safe-to-test" label, which must be done via a labeled event — not checked by label presence — eliminating any race condition on new commits. Add remove-safe-to-test-label.yml to automatically strip the safe-to-test label when a contributor pushes new commits, so a maintainer must explicitly re-label before CI runs again on the updated code. Signed-off-by: Prem Kumar Kalle <prem.kalle@broadcom.com>
1 parent 03b1d4c commit afe2566

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Remove safe-to-test label on new commits
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
- v8
8+
types:
9+
- synchronize
10+
11+
jobs:
12+
remove-label:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
pull-requests: write
16+
if: contains(github.event.pull_request.labels.*.name, 'safe-to-test')
17+
steps:
18+
- name: Remove safe-to-test label
19+
run: gh pr edit "${{ github.event.pull_request.number }}" --remove-label "safe-to-test"
20+
env:
21+
GH_TOKEN: ${{ github.token }}

.github/workflows/tests-integration.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ on:
2525
branches:
2626
- main
2727
- v8
28+
types:
29+
- opened
30+
- synchronize
31+
- reopened
32+
- labeled
2833
paths-ignore:
2934
- "doc/**"
3035
- ".gitpod.yml"
@@ -33,7 +38,13 @@ on:
3338
jobs:
3439
get-sha:
3540
runs-on: ubuntu-latest
36-
if: ${{ github.actor != 'dependabot[bot]' }}
41+
if: |
42+
${{ github.actor != 'dependabot[bot]' && (
43+
github.event.pull_request.author_association == 'OWNER' ||
44+
github.event.pull_request.author_association == 'COLLABORATOR' ||
45+
(github.event_name == 'labeled' &&
46+
github.event.label.name == 'safe-to-test')
47+
) }}
3748
outputs:
3849
gitRef: ${{steps.calculate.outputs.ref}}
3950
steps:

0 commit comments

Comments
 (0)