-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (78 loc) · 3.16 KB
/
move-issue-to-in-progress.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Move Issue to In Progress When Assigned
on:
issues:
types:
- assigned
jobs:
move_to_in_progress:
runs-on: ubuntu-latest
permissions:
issues: write
repository-projects: write # Corrected permission for interacting with repository projects
steps:
- name: Move issue to "🚧 In Progress" in project
uses: actions/github-script@v6
with:
script: |
// Replace with your own organization/user and project number
const projectOwner = 'Computing-For-All'; // Replace with your organization or user name
const projectNumber = 3; // Replace with your project number
// Replace with your specific field name for "Status" and desired "In Progress" status value
const statusFieldName = 'Status'; // Replace with your field name
const inProgressStatusValue = '🚧 In Progress'; // Replace with your exact status value
// Retrieve project ID and field ID for Status
const { data: { user } } = await github.graphql(`
query ($login: String!, $number: Int!) {
user(login: $login) {
projectV2(number: $number) {
id
fields(first: 20) {
nodes {
id
name
... on ProjectV2SingleSelectField {
options {
id
name
}
}
}
}
}
}
}
`, {
login: projectOwner,
number: projectNumber
});
const projectId = user.projectV2.id;
const statusField = user.projectV2.fields.nodes.find(field => field.name === statusFieldName);
if (!statusField) {
throw new Error(`Field "${statusFieldName}" not found in project.`);
}
const inProgressOption = statusField.options.find(option => option.name === inProgressStatusValue);
if (!inProgressOption) {
throw new Error(`Status option "${inProgressStatusValue}" not found in field "${statusFieldName}".`);
}
// Add the issue to the project or update its status if already in the project
const issueNodeId = context.payload.issue.node_id;
// Move the issue to "In Progress" status
await github.graphql(`
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
updateProjectV2ItemFieldValue(input: {
projectId: $projectId
itemId: $itemId
fieldId: $fieldId
value: { singleSelectOptionId: $optionId }
}) {
projectV2Item {
id
}
}
}
`, {
projectId: projectId,
itemId: issueNodeId,
fieldId: statusField.id,
optionId: inProgressOption.id
});