forked from dbt-labs/docs.getdbt.com
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (115 loc) · 3.94 KB
/
add_pr_to_project.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
name: Add PR to project
on:
pull_request_target:
types: [opened,reopened]
jobs:
track_pr:
runs-on: ubuntu-latest
steps:
- uses: octokit/[email protected]
name: Get project data
id: get_project_info
with:
query: |
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}
org: 'dbt-labs'
number: 14
headers: 'GraphQL-Features: projects_next_graphql'
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_NEXT }}
- uses: octokit/[email protected]
name: Add PR to Project
id: add_pr
with:
query: |
mutation($project:ID!, $pr:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $pr}) {
projectNextItem {
id
}
}
}
project: ${{ fromJSON(steps.get_project_info.outputs.data).organization.projectNext.id }}
pr: ${{ github.event.pull_request.node_id}}
headers: 'GraphQL-Features: projects_next_graphql'
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_NEXT }}
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "data.json"
json: ${{ steps.get_project_info.outputs.data }}
- name: Extract date field ID
uses: sergeysova/jq-action@v2
id: date_field_id
with:
cmd:
jq '.organization.projectNext.fields.nodes[] | select(.name == "Date") | .id' data.json
- name: Extract status field ID
uses: sergeysova/jq-action@v2
id: status_field_id
with:
cmd:
jq '.organization.projectNext.fields.nodes[] | select(.name == "Status") | .id' data.json
- name: Extract status field value
uses: sergeysova/jq-action@v2
id: status_field_value
with:
cmd:
jq '.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="Triage") |.id' data.json
- name: Set fields
id: set_fields
uses: octokit/[email protected]
with:
query: |
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
$date_field: ID!
$date_value: String!
) {
set_status: updateProjectNextItemField(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: $status_value
}) {
projectNextItem {
id
}
}
set_date_posted: updateProjectNextItemField(input: {
projectId: $project
itemId: $item
fieldId: $date_field
value: $date_value
}) {
projectNextItem {
id
}
}
}
GITHUB_TOKEN: ${{ secrets.PROJECT_NEXT }}
project: ${{ fromJSON(steps.get_project_info.outputs.data).organization.projectNext.id }}
headers: 'GraphQL-Features: projects_next_graphql'
item: ${{ fromJSON(steps.add_pr.outputs.data).addProjectNextItem.projectNextItem.id }}
status_field: ${{ steps.status_field_id.outputs.value }}
status_value: ${{ steps.status_field_value.outputs.value }}
date_field: ${{ steps.date_field_id.outputs.value }}
date_value: ${{ github.event.pull_request.created_at }}