Skip to content

Commit

Permalink
Update create-jira-issue.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hooni0918 committed Jun 28, 2024
1 parent b341093 commit 688c107
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,40 @@ on:
push:
branches:
- '*'
pull_request:
types: [opened, synchronize, reopened]
issues:
types: [opened, edited]

jobs:
sync_with_jira:
runs-on: ubuntu-latest
steps:
- name: Sync commits with Jira
- name: Checkout code
uses: actions/checkout@v3

- name: Sync activity with Jira
run: |
function extract_issue_key_from_commit_message {
echo "$1" | grep -oE 'JIRA-\d+'
}
JIRA_ISSUE_KEY=$(extract_issue_key_from_commit_message "Update create-jira-issue.yml")
# 예시로 커밋 메시지 사용, 실제 환경에서는 다른 변수 사용 가능
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
JIRA_ISSUE_KEY=$(extract_issue_key_from_commit_message "$COMMIT_MESSAGE")
if [ -z "$JIRA_ISSUE_KEY" ]; then
echo "No JIRA issue key found in commit message."
exit 1
fi
COMMIT_ID="6f2a2640d5fdd55e4fead9548a77940585202111"
COMMIT_MSG="Update create-jira-issue.yml"
COMMIT_ID=$(git rev-parse HEAD)
echo "Syncing commit $COMMIT_ID with JIRA issue $JIRA_ISSUE_KEY"
curl -u "${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \
-X POST \
--data "{\"update\": {\"comment\": [{\"add\": {\"body\": \"Commit '$COMMIT_ID' was added to this issue: $COMMIT_MSG\"}}]}}" \
--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"
env:
Expand Down

0 comments on commit 688c107

Please sign in to comment.