-
Notifications
You must be signed in to change notification settings - Fork 54
136 lines (129 loc) · 6.27 KB
/
update-pr-approved.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Move card to the next review column once dev approved
on:
pull_request_review:
types:
- submitted
jobs:
move_card_to_next_review:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- name: Change design label
if: contains(github.event.pull_request.labels.*.name, 'upcoming design review')
env:
GITHUB_TOKEN: ${{ secrets.BOOSTED_MOD_PERSONAL_TOKEN_CLASSIC }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
curl -L -X POST -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$OWNER/$REPO/issues/$PR_NUMBER/labels -d '{"labels":["ready for design review"]}'
gh api --method DELETE "/repos/$OWNER/$REPO/issues/$PR_NUMBER/labels/upcoming design review"
- name: Change accessibility label
if: contains(github.event.pull_request.labels.*.name, 'upcoming a11y review')
env:
GITHUB_TOKEN: ${{ secrets.BOOSTED_MOD_PERSONAL_TOKEN_CLASSIC }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
curl -L -X POST -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$OWNER/$REPO/issues/$PR_NUMBER/labels -d '{"labels":["ready for a11y review"]}'
gh api --method DELETE "/repos/$OWNER/$REPO/issues/$PR_NUMBER/labels/upcoming a11y review"
- name: Get Project Data
env:
GITHUB_TOKEN: ${{ secrets.BOOSTED_MOD_PERSONAL_TOKEN_CLASSIC }}
ORGANIZATION: ${{ github.repository_owner }}
PR_ID: ${{ github.event.pull_request.node_id }}
PROJECT_NUMBER: ${{ vars.PR_BOARD_PROJECT_NUMBER }}
PROJECT_DESIGN_A11Y_COL: ${{ vars.PR_BOARD_NEED_DESIGN_A11Y_REVIEW_COL_NAME }}
PROJECT_LEAD_COL: ${{ vars.PR_BOARD_NEED_LEAD_DEV_REVIEW_COL_NAME }}
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
fields(first:10) {
nodes {
... on ProjectV2Field {
id
name
}
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
items(first:100) {
nodes {
id
content {
... on PullRequest {
id
}
}
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
# echo `cat project_data.json`
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
echo 'TARGET_COL_ID1='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="${{ env.PROJECT_DESIGN_A11Y_COL }}") |.id' project_data.json) >> $GITHUB_ENV
echo 'TARGET_COL_ID2='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="${{ env.PROJECT_LEAD_COL }}") |.id' project_data.json) >> $GITHUB_ENV
echo 'ITEM_ID='$(jq '.data.organization.projectV2.items.nodes[] | select(.content.id=="${{ env.PR_ID }}") |.id' project_data.json) >> $GITHUB_ENV
- name: Change project card to the design and/or accessibility column
if: contains(github.event.pull_request.labels.*.name, 'upcoming a11y review') || contains(github.event.pull_request.labels.*.name, 'upcoming design review') || contains(github.event.pull_request.labels.*.name, 'ready for a11y review') || contains(github.event.pull_request.labels.*.name, 'ready for design review')
env:
GITHUB_TOKEN: ${{ secrets.BOOSTED_MOD_PERSONAL_TOKEN_CLASSIC }}
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
) {
set_status: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {
singleSelectOptionId: $status_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.TARGET_COL_ID1 }} --silent
- name: Change project card to the lead tech column
if: "!(contains(github.event.pull_request.labels.*.name, 'upcoming a11y review') || contains(github.event.pull_request.labels.*.name, 'upcoming design review') || contains(github.event.pull_request.labels.*.name, 'ready for a11y review') || contains(github.event.pull_request.labels.*.name, 'ready for design review'))"
env:
GITHUB_TOKEN: ${{ secrets.BOOSTED_MOD_PERSONAL_TOKEN_CLASSIC }}
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
) {
set_status: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {
singleSelectOptionId: $status_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.TARGET_COL_ID2 }} --silent