Skip to content

[KAN-48] 서비스 소개 페이지 구현 #13

[KAN-48] 서비스 소개 페이지 구현

[KAN-48] 서비스 소개 페이지 구현 #13

name: Create Jira Issue (Epic, Task, or Bug)
on:
issues:
types:
- opened
jobs:
create-issue:
name: Create Jira Issue
runs-on: ubuntu-latest
steps:
- name: Login to Jira
uses: atlassian/gajira-login@v3
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
- name: Checkout dev code
uses: actions/checkout@v4
with:
ref: dev
- name: Template Issue Parser
uses: stefanbuck/github-issue-praser@v3
id: template-issue-parser
with:
template-path: '.github/ISSUE_TEMPLATE/epic-issue-form.yml'
- name: Determine issue type from template_tag field
id: issue-type
run: |
echo "template_tag='${{ steps.template-issue-parser.outputs.issueparser_templateTag }}'"
if [ "${{ steps.template-issue-parser.outputs.issueparser_templateTag }}" = "epic" ]; then
echo "type=Epic" >> $GITHUB_OUTPUT
elif [ "${{ steps.template-issue-parser.outputs.issueparser_templateTag }}" = "task" ]; then
echo "type=Task" >> $GITHUB_OUTPUT
elif [ "${{ steps.template-issue-parser.outputs.issueparser_templateTag }}" = "bug" ]; then
echo "type=Bug" >> $GITHUB_OUTPUT
else
echo "type=Unknown" >> $GITHUB_OUTPUT
fi
- name: Issue Parser
uses: stefanbuck/github-issue-praser@v3
id: issue-parser
with:
template-path: ${{ steps.issue-type.outputs.type == 'Epic' && '.github/ISSUE_TEMPLATE/epic-issue-form.yml' || steps.issue-type.outputs.type == 'Task' && '.github/ISSUE_TEMPLATE/task-issue-form.yml' || steps.issue-type.outputs.type == 'Bug' && '.github/ISSUE_TEMPLATE/bug-issue-form.yml' || '' }}
- name: Log Issue Parser
run: |
echo 'Issue Type: ${{ steps.issue-type.outputs.type }}'
echo 'Ticket Number: ${{ steps.issue-parser.outputs.__ticket_number }}'
echo 'Parsed JSON: ${{ steps.issue-parser.outputs.jsonString }}'
- name: Convert markdown to Jira Syntax
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: Prepare fields JSON
id: prepare-fields
run: |
if [ '${{ steps.issue-type.outputs.type }}' = "Task" ]; then
PARENT_KEY="${{ steps.issue-parser.outputs.issueparser_parentKey }}"
if [ -n "$PARENT_KEY" ]; then
echo "json={\"parent\": {\"key\": \"$PARENT_KEY\"}}" >> $GITHUB_OUTPUT
else
echo "json=" >> $GITHUB_OUTPUT
fi
else
echo "json=" >> $GITHUB_OUTPUT
fi
- name: Create Jira Issue
id: create
uses: atlassian/gajira-create@v3
if: steps.issue-type.outputs.type == 'Epic' || steps.issue-type.outputs.type == 'Task' || steps.issue-type.outputs.type == 'Bug'
with:
project: KAN
issuetype: ${{ steps.issue-type.outputs.type }}
summary: '[client]${{ github.event.issue.title }}'
description: '${{ steps.md2jira.outputs.output-text }}'
fields: ${{ steps.prepare-fields.outputs.json }}
- name: Log created issue
if: steps.issue-type.outputs.type == 'Epic' || steps.issue-type.outputs.type == 'Task' || steps.issue-type.outputs.type == 'Bug'
run: echo "Jira Issue ${{ steps.create.outputs.issue }} was created"
- name: Create branch with Ticket number
if: steps.issue-type.outputs.type == 'Epic' || steps.issue-type.outputs.type == 'Task' || steps.issue-type.outputs.type == 'Bug'
run: |
ISSUE_NUMBER="${{ steps.create.outputs.issue }}"
ISSUE_TITLE="${{ steps.issue-parser.outputs.issueparser_branch}}"
BRANCH_NAME="${ISSUE_NUMBER}-$(echo ${ISSUE_TITLE} | sed 's/ /-/g')"
git checkout -b "${BRANCH_NAME}"
git push origin "${BRANCH_NAME}"
- name: Update GitHub Issue title
if: steps.issue-type.outputs.type == 'Epic' || steps.issue-type.outputs.type == 'Task' || steps.issue-type.outputs.type == 'Bug'
uses: actions-cool/issues-helper@v3
with:
actions: 'update-issue'
token: ${{ secrets.GITHUB_TOKEN }}
title: '[${{ steps.create.outputs.issue }}] ${{ github.event.issue.title }}'
- name: Link JIRA Issue with Branch
if: steps.issue-type.outputs.type == 'Epic' || steps.issue-type.outputs.type == 'Task' || steps.issue-type.outputs.type == 'Bug'
env:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
run: |
ISSUE_KEY="${{ steps.create.outputs.issue }}"
BRANCH_BASE="${{ steps.issue-parser.outputs.issueparser_branch }}"
if [ -z "$BRANCH_BASE" ]; then
BRANCH_BASE="feature"
fi
BRANCH_NAME="${ISSUE_KEY}-$(echo $BRANCH_BASE | tr ' ' '-' | tr -cd '[:alnum:]-/')"
BRANCH_URL="https://github.com/${{ github.repository }}/tree/${BRANCH_NAME}"
echo "Linking JIRA Issue $ISSUE_KEY with Branch $BRANCH_NAME"
curl -u "${JIRA_USER_EMAIL}:${JIRA_API_TOKEN}" \
-X POST \
-H "Content-Type: application/json" \
-d "{\"branches\": [{\"name\": \"$BRANCH_NAME\", \"url\": \"$BRANCH_URL\"}]}" \
"${JIRA_BASE_URL}/rest/dev-status/1.0/issue/detail?issueId=${ISSUE_KEY}&type=branch"
- name: Add comment with Jira issue link
if: steps.issue-type.outputs.type == 'Epic' || steps.issue-type.outputs.type == 'Task' || steps.issue-type.outputs.type == 'Bug'
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: 'Jira Issue Created: [${{ steps.create.outputs.issue }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.create.outputs.issue }})'