-
Notifications
You must be signed in to change notification settings - Fork 25
/
gh_api_lib_organization.sh
57 lines (55 loc) · 1.58 KB
/
gh_api_lib_organization.sh
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
#!/bin/bash
# getOrganizationProjectID queries the github api for the specific project uuid
# 1: organization (string)
# 2: project id (number)
function getOrganizationProjectID() {
local ORGANIZATION=$1
local PROJECT_NUMBER=$2
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER | jq .data.organization.projectV2.id | sed -e 's+"++g'
}
# getOrganizationProjectFields queries the github api for the specific project fields
# 1: project id (uuid)
function getOrganizationProjectFields() {
local PROJECT_ID=$1
gh api graphql -f query='
query($projectId: ID!){
node(id: $projectId) {
... on ProjectV2 {
fields(first: 100) {
nodes {
... on ProjectV2Field {
id
name
}
... on ProjectV2IterationField {
id
name
configuration {
iterations {
startDate
id
title
}
}
}
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}' -f projectId=$PROJECT_ID | jq .data.node.fields > $TMP_STORE_LOCATION
}