🐶 CCTV AT 구현 #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |