-
Notifications
You must be signed in to change notification settings - Fork 2
46 lines (38 loc) · 1.54 KB
/
create-jira-issue.yml
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
name: Sync GitHub Actions with Jira
on:
push:
branches:
- '*'
jobs:
sync_with_jira:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- 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+')
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에 커밋 정보 동기화
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")
echo "JIRA Response: $RESPONSE"
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_BASEURL: ${{ secrets.JIRA_BASEURL }}
JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}