-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (122 loc) · 4.87 KB
/
create-issue.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
name: 프로젝트 이슈 생성 연결 자동화
on:
issues:
types:
- opened
jobs:
create-project-issue:
permissions: write-all
name: 이슈 생성 - 프로젝트 연결 자동화
runs-on: ubuntu-latest
steps:
- name: 이슈 담당자 자동 할당
uses: pozil/auto-assign-issue@v2
with:
assignees: ${{ github.actor }}
- name: 프로젝트 정보 가져오기
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
ORGANIZATION: IoTeaTime
PROJECT_NUMBER: 4
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectV2(number: $number) {
id
fields(first:20) {
nodes {
... on ProjectV2Field {
id
name
}
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'START_DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Start date") | .id' project_data.json) >> $GITHUB_ENV
echo 'TEAM_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Team") | .id' project_data.json) >> $GITHUB_ENV
echo 'SERVER_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Team") | .options[] | select(.name=="Server") | .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 'IN_PROGRESS_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name== "In progress") | .id' project_data.json) >> $GITHUB_ENV
- name: 이슈를 프로젝트에 추가
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql -f query='
mutation($project:ID!, $issue:ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) {
item {
id
}
}
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.item.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
- name: 오늘 날짜 가져오기
run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
- name: 커스텀 필드 업데이트 (생성 일자 추가)
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$team_field: ID!
$team_value: String!
$status_field: ID!
$status_value: String!
$start_date_field: ID!
$start_date_value: Date!
) {
set_team_server: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $team_field
value: {
singleSelectOptionId: $team_value
}
}) {
projectV2Item {
id
}
}
set_status_in_progress: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {
singleSelectOptionId: $status_value
}
}) {
projectV2Item {
id
}
}
set_start_date: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $start_date_field
value: {
date: $start_date_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID \
-f team_field=$TEAM_FIELD_ID -f team_value=${{ env.SERVER_OPTION_ID }} \
-f status_field=$STATUS_FIELD_ID -f status_value=${{ env.IN_PROGRESS_OPTION_ID }} \
-f start_date_field=$START_DATE_FIELD_ID -f start_date_value=$DATE --silent