github-issue-create #54
This file contains hidden or 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: 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 | |
| }); |