@@ -2,27 +2,49 @@ name: 🏷 Label Pull Requests
22
33on :
44 pull_request :
5- types : [opened, edited, reopened]
5+ types : [opened, edited, reopened, closed ]
66
77jobs :
88
9- label-pull-requests :
10- runs-on : ubuntu-latest
11- permissions :
12- contents : read
13- pull-requests : write
9+ label-pull-requests :
10+ runs-on : ubuntu-latest
11+ permissions :
12+ contents : read
13+ pull-requests : write
1414
15- steps :
16- # If PR title starts with "Internal: " then add the "Internal" label
17- - name : Label Internal Pull Requests
18- if : " startsWith(github.event.pull_request.title, 'Internal: ')"
19- uses : actions/github-script@v7
20- with :
21- github-token : ${{ secrets.GITHUB_TOKEN }}
22- script : |
23- github.rest.issues.addLabels({
24- issue_number: context.issue.number,
25- owner: context.repo.owner,
26- repo: context.repo.repo,
27- labels: ['Internal']
28- })
15+ steps :
16+ # If PR title starts with "Internal: " then add the "Internal" label
17+ - name : Label Internal Pull Requests
18+ if : " startsWith(github.event.pull_request.title, 'Internal: ')"
19+ uses : actions/github-script@v7
20+ with :
21+ github-token : ${{ secrets.GITHUB_TOKEN }}
22+ script : |
23+ github.rest.issues.addLabels({
24+ issue_number: context.issue.number,
25+ owner: context.repo.owner,
26+ repo: context.repo.repo,
27+ labels: ['Internal']
28+ })
29+
30+ # Remove "run-visual-tests" label if the pull request is closed
31+ - name : Remove run-visual-tests Label
32+ if : github.event_name == 'pull_request' && github.event.action == 'closed'
33+ uses : actions/github-script@v7
34+ with :
35+ github-token : ${{ secrets.GITHUB_TOKEN }}
36+ script : |
37+ const { data: labels } = await github.rest.issues.listLabelsOnIssue({
38+ issue_number: context.issue.number,
39+ owner: context.repo.owner,
40+ repo: context.repo.repo
41+ });
42+ const visualTestsLabel = labels.find(label => label.name === 'run-visual-tests');
43+ if (visualTestsLabel) {
44+ await github.rest.issues.removeLabel({
45+ issue_number: context.issue.number,
46+ name: 'run-visual-tests',
47+ owner: context.repo.owner,
48+ repo: context.repo.repo
49+ });
50+ }
0 commit comments