-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Sync GitHub Actions with Jira and Manage Branches | ||
name: Sync GitHub Actions with Jira | ||
|
||
on: | ||
push: | ||
|
@@ -14,39 +14,33 @@ jobs: | |
|
||
- name: Extract JIRA Issue Key and Sync | ||
run: | | ||
# 최신 커밋 메시지 가져오기 | ||
# 최근 커밋 메시지 가져오기 | ||
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | ||
echo "Commit Message: $COMMIT_MESSAGE" | ||
# JIRA 이슈 키 추출 | ||
JIRA_ISSUE_KEY=$(echo "$COMMIT_MESSAGE" | grep -oE 'JIRA-\d+') | ||
# JIRA 이슈 키가 없다면 오류 출력 후 종료 | ||
echo "JIRA Issue Key: $JIRA_ISSUE_KEY" | ||
# JIRA 이슈 키 검증 | ||
if [ -z "$JIRA_ISSUE_KEY" ]; then | ||
echo "No JIRA issue key found in commit message." | ||
exit 1 | ||
fi | ||
# 커밋 ID 가져오기 | ||
COMMIT_ID=$(git rev-parse HEAD) | ||
echo "Commit ID: $COMMIT_ID" | ||
# JIRA에 커밋 정보 동기화 | ||
curl -u "${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \ | ||
RESPONSE=$(curl -s -u "${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \ | ||
-X POST \ | ||
--data "{\"update\": {\"comment\": [{\"add\": {\"body\": \"Commit '$COMMIT_ID' was added to this issue: $COMMIT_MESSAGE\"}}]}}" \ | ||
-H "Content-Type: application/json" \ | ||
"${{ secrets.JIRA_BASEURL }}/rest/api/2/issue/$JIRA_ISSUE_KEY" | ||
"${{ secrets.JIRA_BASEURL }}/rest/api/2/issue/$JIRA_ISSUE_KEY") | ||
echo "JIRA Response: $RESPONSE" | ||
env: | ||
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} | ||
JIRA_BASEURL: ${{ secrets.JIRA_BASEURL }} | ||
JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }} | ||
|
||
- name: Create Branch on Issue Opened | ||
run: | | ||
ISSUE_TITLE="${{ github.event.issue.title }}" | ||
# 브랜치 이름 생성 (공백 및 특수문자를 하이픈으로 치환) | ||
BRANCH_NAME=$(echo "$ISSUE_TITLE" | sed 's/[^a-zA-Z0-9가-힣]/-/g' | tr '[:upper:]' '[:lower:]') | ||
# 브랜치 생성 및 푸시 | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
git checkout -b "$BRANCH_NAME" | ||
git push origin "$BRANCH_NAME" |