-
Notifications
You must be signed in to change notification settings - Fork 3.2k
97 lines (94 loc) · 3.74 KB
/
triage_update_status.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
90
91
92
93
94
95
96
97
name: 'Set Issue Status'
on:
# makes this workflow reusable
workflow_call:
inputs:
status:
description: 'Which status column?'
default: 'New Issue'
required: false
type: string
secrets:
ADD_TO_TRIAGE_BOARD_TOKEN:
required: true
jobs:
move-to-requested-status:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
STATUS: ${{ inputs.status || 'New Issue' }}
GITHUB_TOKEN: ${{ secrets.ADD_TO_TRIAGE_BOARD_TOKEN }}
ORGANIZATION: 'cypress-io'
REPOSITORY: ${{ github.event.repository.name }}
PROJECT_NUMBER: 9
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
gh api graphql -f query='
query($org: String!, $repo: String!, $project: Int!, $issue: Int!) {
organization(login: $org) {
repository(name: $repo) {
issue(number: $issue) {
projectItems(first: 10, includeArchived: false) {
nodes {
id
fieldValueByName(name: "Status") {
... on ProjectV2ItemFieldSingleSelectValue {
name
field {
... on ProjectV2SingleSelectField {
project {
... on ProjectV2 {
id
number
}
}
}
}
}
}
}
}
}
}
projectV2(number: $project) {
field(name: "Status") {
... on ProjectV2SingleSelectField {
id
options {
id
name
}
}
}
}
}
}' -f org=$ORGANIZATION -f repo=$REPOSITORY -F issue=$ISSUE_NUMBER -F project=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq -r '.data.organization.repository.issue.projectItems.nodes[].fieldValueByName.field.project | select(.number == ${{ env.PROJECT_NUMBER }}) | .id' project_data.json) >> $GITHUB_ENV
echo 'PROJECT_ITEM_ID='$(jq -r '.data.organization.repository.issue.projectItems.nodes[] | select(.fieldValueByName.field.project.number == ${{ env.PROJECT_NUMBER }}) | .id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq -r '.data.organization.projectV2.field | .id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_OPTION_ID='$(jq -r '.data.organization.projectV2.field.options[] | select(.name== "${{ env.STATUS }}") | .id' project_data.json) >> $GITHUB_ENV
- name: Move issue to new status
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_TRIAGE_BOARD_TOKEN }}
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
) {
updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {
singleSelectOptionId: $status_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$PROJECT_ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=$STATUS_OPTION_ID