-
Notifications
You must be signed in to change notification settings - Fork 16
64 lines (60 loc) · 2.06 KB
/
Copy pathproject-status-label.yaml
File metadata and controls
64 lines (60 loc) · 2.06 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Add Label on Project Status Change
on:
workflow_dispatch:
project_v2_item:
types: [edited]
jobs:
add-label:
runs-on: ubuntu-latest
steps:
- name: Check project item status and add label
uses: actions/github-script@v7
with:
script: |
try {
const { data: item } = await github.graphql(`
query($id: ID!) {
node(id: $id) {
... on ProjectV2Item {
content {
... on Issue {
number
repository {
name
owner { login }
}
}
}
fieldValues(first: 10) {
nodes {
... on ProjectV2ItemFieldSingleSelectValue {
field { name }
name
}
}
}
}
}
}
`, { id: context.payload.project_v2_item.node_id });
const statusField = item.fieldValues.nodes.find(f => f.field.name === "Status");
console.log("current status:", statusField?.name);
if (
statusField?.name === "Need To Verify" &&
item.content?.number
) {
const issue = item.content;
await github.rest.issues.addLabels({
owner: issue.repository.owner.login,
repo: issue.repository.name,
issue_number: issue.number,
labels: ["kind/need-to-verify"]
});
console.log("Label added: kind/need-to-verify");
} else {
console.log("Not a matching item, skip");
}
} catch (error) {
console.error("Action failed:", error.message);
throw error;
}