-
Notifications
You must be signed in to change notification settings - Fork 920
46 lines (39 loc) · 1.62 KB
/
pr-label-cleanup.yml
File metadata and controls
46 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Auto-remove run-ci label when new commits are pushed to external PRs
# This ensures maintainers must re-approve after code changes
name: PR Label Cleanup
on:
pull_request:
types: [synchronize] # New commits pushed
permissions:
pull-requests: write
jobs:
remove-label:
# Only run if PR has run-ci label and author is external
if: contains(github.event.pull_request.labels.*.name, 'run-ci')
runs-on: ubuntu-latest
steps:
- name: Check if external contributor
id: check
run: |
ASSOC="${{ github.event.pull_request.author_association }}"
if [[ "$ASSOC" =~ ^(OWNER|MEMBER|COLLABORATOR)$ ]]; then
echo "is_external=false" >> "$GITHUB_OUTPUT"
echo "PR author has $ASSOC access, keeping label"
else
echo "is_external=true" >> "$GITHUB_OUTPUT"
echo "PR author is $ASSOC (external), will remove label"
fi
- name: Remove run-ci label
if: steps.check.outputs.is_external == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Removing run-ci label from PR #${{ github.event.pull_request.number }}"
gh pr edit ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} \
--remove-label "run-ci"
# Post a comment explaining why
gh pr comment ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} \
--body "New commits detected. The \`run-ci\` label has been removed for security.
A maintainer can re-approve by commenting \`@flashinfer-bot run\`"