Skip to content

Commit de875e6

Browse files
committed
Remove the safe-to-test label automatically (#141)
*Issue #, if available:* *Description of changes:* Extract the fix in 3f073a4 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 0629ba4 commit de875e6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

.github/workflows/integration-tests.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
push:
66
branches: ["main"]
77
pull_request_target:
8-
types: [opened, synchronize, reopened, ready_for_review, labeled]
8+
types: [labeled]
99

1010
env:
1111
CARGO_TERM_COLOR: always
@@ -17,7 +17,7 @@ jobs:
1717
# Run if:
1818
# 1. Manual trigger or push to main, OR
1919
# 2. PR from trusted author (COLLABORATOR), OR
20-
# 3. PR from untrusted author with "safe to test" label
20+
# 3. PR with "safe to test" label
2121
if: |
2222
github.event_name != 'pull_request_target' ||
2323
github.event.pull_request.author_association == 'COLLABORATOR' ||
@@ -26,8 +26,26 @@ jobs:
2626
permissions:
2727
id-token: write
2828
contents: read
29+
issues: write
30+
pull-requests: write
31+
32+
env:
33+
LABEL_NAME: safe-to-test
34+
REPO: ${{ github.event.pull_request.base.repo.full_name }}
35+
PR_NUMBER: ${{ github.event.pull_request.number }}
2936

3037
steps:
38+
- name: Remove label
39+
run: |
40+
echo "Removing label '$LABEL_NAME' from PR #$PR_NUMBER on repo $REPO"
41+
gh_status=$(gh api "repos/$REPO/issues/$PR_NUMBER/labels/$LABEL_NAME" -X DELETE | jq ".status // empty" --raw-output)
42+
case $gh_status in
43+
"") echo "Label removed" ;;
44+
404) echo "Label not found — ignoring" ;;
45+
*) echo "unexpected HTTP $gh_status" && exit 1 ;;
46+
esac
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3149
- name: Checkout
3250
uses: actions/checkout@v5
3351
with:

0 commit comments

Comments
 (0)