-
-
Notifications
You must be signed in to change notification settings - Fork 6
51 lines (45 loc) · 1.68 KB
/
label-pull-requests.yml
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
47
48
49
50
51
name: 🏷 Label Pull Requests
on:
pull_request:
types: [opened, edited, reopened, closed]
jobs:
label-pull-requests:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
# If PR title starts with "Internal: " then add the "Internal" label
- name: Label Internal Pull Requests
if: "startsWith(github.event.pull_request.title, 'Internal: ')"
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Internal']
})
# Remove "run-visual-tests" label if the pull request is closed
- name: Remove run-visual-tests Label
if: github.event_name == 'pull_request' && github.event.action == 'closed'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
const visualTestsLabel = labels.find(label => label.name === 'run-visual-tests');
if (visualTestsLabel) {
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
name: 'run-visual-tests',
owner: context.repo.owner,
repo: context.repo.repo
});
}