Skip to content

Commit 40ad224

Browse files
authored
Merge pull request #30 from YAPP-Github/doyeonk429-patch-1
chore: 자동화 로직 업데이트
2 parents 2a69a9e + 36cf118 commit 40ad224

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/create-jira-issue.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,56 @@ jobs:
9898
- name: Log created issue
9999
run: echo "Jira Issue ${{ steps.issue-parser.outputs.parentKey }}/${{ steps.create.outputs.issue }} was created"
100100

101+
- name: Extract task list
102+
id: extract-tasks
103+
run: |
104+
echo "${{ steps.issue-parser.outputs.issueparser_tasks }}" > tasks.md
105+
# Markdown 체크박스 형식에서 텍스트만 추출
106+
grep -oP '(?<=- \[ \] ).*' tasks.md > tasks.txt
107+
echo "📋 추출된 작업 목록:"
108+
cat tasks.txt
109+
# JSON 배열로 변환
110+
echo "TASKS_JSON=$(jq -R -s -c 'split("\n") | map(select(length > 0))' tasks.txt)" >> $GITHUB_ENV
111+
112+
- name: Create Jira Sub-tasks
113+
if: ${{ env.TASKS_JSON != '[]' }}
114+
uses: actions/github-script@v7
115+
with:
116+
github-token: ${{ secrets.GITHUB_TOKEN }}
117+
script: |
118+
const tasks = JSON.parse(process.env.TASKS_JSON);
119+
const parentKey = '${{ steps.create.outputs.issue }}';
120+
const fetch = require('node-fetch');
121+
122+
for (const task of tasks) {
123+
const res = await fetch(`${process.env.JIRA_BASE_URL}/rest/api/3/issue`, {
124+
method: 'POST',
125+
headers: {
126+
'Authorization': `Basic ${Buffer.from(`${process.env.JIRA_USER_EMAIL}:${process.env.JIRA_API_TOKEN}`).toString('base64')}`,
127+
'Content-Type': 'application/json'
128+
},
129+
body: JSON.stringify({
130+
fields: {
131+
project: { key: "BOOK" },
132+
summary: task,
133+
issuetype: { name: "Sub-task" },
134+
parent: { key: parentKey }
135+
}
136+
})
137+
});
138+
139+
if (!res.ok) {
140+
const err = await res.text();
141+
core.setFailed(`❌ Failed to create sub-task: ${err}`);
142+
} else {
143+
console.log(`✅ Created sub-task: ${task}`);
144+
}
145+
}
146+
env:
147+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
148+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
149+
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
150+
101151
- name: Checkout both branches
102152
uses: actions/checkout@v4
103153
with:

0 commit comments

Comments
 (0)