Skip to content

KAN-154 ⚙️ 이슈 연결 테스트 #1

KAN-154 ⚙️ 이슈 연결 테스트

KAN-154 ⚙️ 이슈 연결 테스트 #1

Workflow file for this run

name: 이슈 생성 연결 자동화
on:
issues:
types:
- opened
jobs:
create-jira-issue:
permissions: write-all
name: Jira 이슈 생성
runs-on: ubuntu-latest
steps:
- name: 이슈 담당자 자동 할당
uses: pozil/auto-assign-issue@v2
with:
assignees: ${{ github.actor }}
- name: 원채 Jira 로그인
uses: atlassian/gajira-login@v3
if: github.actor == 'ywonchae1'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_WONCHAE_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_WONCHAE_USER_EMAIL }}
- name: 유진 Jira 로그인
uses: atlassian/gajira-login@v3
if: github.actor == 'sseoU'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_YOUJIN_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_YOUJIN_USER_EMAIL }}
- name: 민석 Jira 로그인
uses: atlassian/gajira-login@v3
if: github.actor == 'seok019283501'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_MINSEOK_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_MINSEOK_USER_EMAIL }}
- name: 경재 Jira 로그인
uses: atlassian/gajira-login@v3
if: github.actor == 'bestKUFO'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_KYONGJAE_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_KYONGJAE_USER_EMAIL }}
- name: 지인 Jira 로그인
uses: atlassian/gajira-login@v3
if: github.actor == 'OziinG'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_JIIN_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_JIIN_USER_EMAIL }}
- name: Main 브랜치 체크아웃
uses: actions/checkout@v4
with:
ref: main
- name: Issue Parser
uses: stefanbuck/github-issue-praser@v3
id: issue-parser
with:
template-path: '.github/ISSUE_TEMPLATE/2-feature-issue-form.yml'
- name: 이슈 Markdown 문법을 Jira 문법으로 변환
uses: peter-evans/jira2md@v1
id: md2jira
with:
input-text: |
### Github Issue Link
- ${{ github.event.issue.html_url }}
${{ github.event.issue.body }}
mode: md2jira
- name: Jira에 이슈 생성
id: create
uses: atlassian/gajira-create@v3
with:
project: KAN
issuetype: Task
summary: "${{ github.event.issue.title }}"
description: "${{ steps.md2jira.outputs.output-text }}"
fields: |
{
"parent": {
"key": "${{ steps.issue-parser.outputs.issueparser_parentKey }}"
}
}
- name: 이슈 제목 수정
uses: actions-cool/issues-helper@v3
with:
actions: "update-issue"
title: "${{ steps.create.outputs.issue }} ${{ github.event.issue.title }}"
create-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
}
... 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== "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=$SERVER_OPTION_ID \
-f status_field=$STATUS_FIELD_ID -f status_value=$IN_PROGRESS_OPTION_ID \
-f start_date_field=$START_DATE_FIELD_ID -f start_date_value=$DATE --silent