-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (95 loc) · 3.51 KB
/
github-issue-create.yml
File metadata and controls
108 lines (95 loc) · 3.51 KB
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
name: Create GitHub Issue from Jira Task
on:
repository_dispatch:
types: [github-issue-create]
jobs:
create-issue:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Parse labels and determine template type
id: parse_labels
run: |
# 라벨 CSV 문자열 추출
labels_csv="${{ github.event.client_payload.labels }}"
# 쉼표로 분할하여 배열 생성
IFS=',' read -ra labels_array <<< "$labels_csv"
# 템플릿 타입 결정 (기본값: todo)
template_type="todo"
for label in "${labels_array[@]}"; do
# 대소문자 구분 없이 비교
label_lower=$(echo "$label" | tr '[:upper:]' '[:lower:]')
case $label_lower in
*bug*)
template_type="bug"
break
;;
*feature*)
template_type="feature"
break
;;
esac
done
# 결과 출력
echo "template_type=$template_type" >> $GITHUB_OUTPUT
- name: Load and process template
id: process_template
run: |
# 변수 추출
template_type="${{ steps.parse_labels.outputs.template_type }}"
template_file=".github/ISSUE_TEMPLATE/$template_type-report.md"
jira_description="${{ github.event.client_payload.description }}"
assignee="${{ github.event.client_payload.assignee }}"
parent_key="${{ github.event.client_payload.parent_key }}"
issue_key="${{ github.event.client_payload.issue_key }}"
# 할당 정보 헤더 생성
header="### 📋 할당 정보\n- **할당자:** $assignee\n- **상위 이슈:** $parent_key\n\n"
# 템플릿 메타 데이터 제거 후 내용 로드
template_content=$(awk '/^---$/ {count++; next} count==1 {next} 1' "$template_file")
# 템플릿 유형별 설명 섹션 설정
case $template_type in
bug)
section_header="### 🐞 어떤 버그인가요?"
;;
feature)
section_header="### 🚀 어떤 기능인가요?"
;;
*)
section_header="### 🚀 이슈 설명"
;;
esac
# Jira 설명을 템플릿에 삽입
processed_content=$(
echo -e "$header"
echo "$template_content" |
awk -v header="$section_header" -v desc="$jira_description" '
$0 ~ header {
print $0
print desc
getline
next
}
/^>/ { next }
1
'
)
# 멀티라인 출력으로 body 설정
{
echo "body<<EOF"
echo "$processed_content"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Create GitHub Issue
uses: actions/github-script@v6
with:
script: |
const { summary, issue_key } = context.payload.client_payload;
const body = `${{ steps.process_template.outputs.body }}`;
const title = `[${issue_key}] ${summary}`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body
});