-
Notifications
You must be signed in to change notification settings - Fork 47
43 lines (38 loc) · 1.12 KB
/
add-label-to-new-issue.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
name: Add label to new issue
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
label-new-issue:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "18.x"
- uses: actions/github-script@v7
with:
script: |
const issue = await github.rest.issues.get({
owner: context.issue.owner,
repo: context.issue.repo,
issue_number: context.issue.number
});
const statusLabel = issue.data.labels.find(({ name }) =>
name.startsWith("status:")
);
if (statusLabel === undefined) {
await github.rest.issues.addLabels({
owner: context.issue.owner,
repo: context.issue.repo,
issue_number: context.issue.number,
labels: ["status:triaging"]
});
} else {
console.log(`Issue already has a status: ${statusLabel.name}`);
}