Skip to content

[feat] 마이페이지 수정 항목 분기화 #72

[feat] 마이페이지 수정 항목 분기화

[feat] 마이페이지 수정 항목 분기화 #72

name: Create Jira Issue and Update Story
on:
issues:
types:
- opened
permissions:
contents: write
issues: write
jobs:
create-jira-issue:
name: Create Jira Issue and Update Story
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 Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: dev
token: ${{ secrets.GITHUB_TOKEN }}
- name: Parse Issue Inputs
id: issue-parser
uses: actions/github-script@v6
with:
script: |
const issueBody = context.payload.issue.body;
console.log("Issue Body:", issueBody);
const storyMatch = issueBody.match(/### 🌳 기능 구현 키 \(Story Ticket Number\)\n\n([A-Z]+-[0-9]+)/);
const branchMatch = issueBody.match(/### 🍃브랜치명 \(Branch\)\n\n([a-zA-Z0-9_\-\/.]+)/);
if (storyMatch) {
core.setOutput('storyKey', storyMatch[1]);
console.log("✅ Extracted storyKey:", storyMatch[1]);
} else {
core.setFailed("❌ storyKey 값을 찾을 수 없습니다. Issue Template을 확인하세요.");
}
if (branchMatch) {
core.setOutput('branch', branchMatch[1]);
console.log("✅ Extracted branch:", branchMatch[1]);
} else {
core.setFailed("❌ branch 값을 찾을 수 없습니다. Issue Template을 확인하세요.");
}
- name: Move Story to "In Progress"
run: |
echo "Moving Jira Story ${{ steps.issue-parser.outputs.storyKey }} to In Progress"
RESPONSE=$(curl -s -o response.txt -w "\nHTTP_STATUS=%{http_code}" -u "${{ secrets.JIRA_USER_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \
-X POST -H "Content-Type: application/json" \
--data '{"transition": {"id": "2"}}' \
"${{ secrets.JIRA_BASE_URL }}/rest/api/3/issue/${{ steps.issue-parser.outputs.storyKey }}/transitions")
HTTP_STATUS=$(echo "$RESPONSE" | grep HTTP_STATUS | cut -d= -f2)
echo "Jira API Response:"
cat response.txt
echo "HTTP Status Code: $HTTP_STATUS"
if [[ "$HTTP_STATUS" -ne 204 ]]; then
echo "ERROR: Failed to transition Jira Story to In Progress. HTTP Status: $HTTP_STATUS"
exit 1
else
echo "SUCCESS: Jira Story transitioned to In Progress!"
fi
- name: Debug Jira Story Key
run: |
echo "Extracted Jira Story Key: '${{ steps.issue-parser.outputs.storyKey }}'"
- name: Create Branch
run: |
BRANCH_NAME="${{ steps.issue-parser.outputs.branch }}"
if [ -z "$BRANCH_NAME" ]; then
BRANCH_NAME="feature/default-branch"
echo "⚠️ Warning: Branch name was empty. Using default: $BRANCH_NAME"
fi
echo "Switching to new branch: $BRANCH_NAME"
git checkout -b "$BRANCH_NAME"
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git "$BRANCH_NAME"
- name: Debug Issue Parser Outputs
run: |
echo "All Parsed Outputs:"
echo "${{ toJson(steps.issue-parser.outputs) }}"
- name: Add Comment with Jira Sub-task Link
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: 'Jira Sub-task Updated: [${{ steps.issue-parser.outputs.subtaskKey }}](${{ secrets.JIRA_BASE_URL }}/browse/${{ steps.issue-parser.outputs.subtaskKey }})'