-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (88 loc) · 3.15 KB
/
close-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
name: 프로젝트 이슈 닫기 연결 자동화
on:
issues:
types:
- closed
jobs:
close-project-issue:
permissions: write-all
name: 이슈 닫기 - 프로젝트 연결 자동화
runs-on: ubuntu-latest
steps:
- 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
}
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'END_DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "End date") | .id' project_data.json) >> $GITHUB_ENV
- name: 오늘 날짜 가져오기
run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
- name: 이슈 번호로 프로젝트 아이템 가져오기
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
ORGANIZATION: IoTeaTime
REPO_NAME: meong-ha-nyang-server
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
gh api graphql -f query='
query(
$org: String!,
$repoName: String!,
$issueNumber: Int!
) {
organization(login: $org) {
repository(name: $repoName) {
issue(number: $issueNumber) {
id
projectItems(last: 1) {
nodes {
id
}
}
}
}
}
}' -f org=$ORGANIZATION -f repoName=$REPO_NAME -F issueNumber=$ISSUE_NUMBER > project_data.json
echo 'ITEM_ID='$(jq '.data.organization.repository.issue.projectItems.nodes[0].id' project_data.json) >> $GITHUB_ENV
- name: 단일 선택 필드 업데이트
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$end_date_field: ID!
$end_date_value: Date!
) {
set_end_date: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $end_date_field
value: {
date: $end_date_value
}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f end_date_field=$END_DATE_FIELD_ID -f end_date_value=$DATE --silent