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 authored Jun 28, 2024
1 parent 5cab32f commit daccc0a
Showing 1 changed file with 12 additions and 30 deletions.
42 changes: 12 additions & 30 deletions .github/workflows/create-jira-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,26 @@ jobs:
sync_with_jira:
runs-on: ubuntu-latest
steps:
- name: Sync commits with Jira
- name: Setup environment
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_ID="6f2a2640d5fdd55e4fead9548a77940585202111"
COMMIT_MSG="Update create-jira-issue.yml"
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\"}}]}}" \
-H "Content-Type: application/json" \
"${{ secrets.JIRA_BASEURL }}/rest/api/2/issue/$JIRA_ISSUE_KEY"
env:
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_BASEURL: ${{ secrets.JIRA_BASEURL }}
JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}


- name: Sync commits with Jira
if: github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags/')
run: |
JIRA_ISSUE_KEY=extract_issue_key_from_commit_message "${{ github.event.head_commit.message }}"
curl -u ${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }} \
JIRA_ISSUE_KEY=$(extract_issue_key_from_commit_message "${{ github.event.head_commit.message }}")
if [ -z "$JIRA_ISSUE_KEY" ]; then
echo "No JIRA issue key found in commit message."
exit 1
fi
COMMIT_ID="${{ github.event.head_commit.id }}"
COMMIT_MSG="${{ github.event.head_commit.message }}"
curl -u "${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \
-X POST \
--data '{
"update": {
"comment": [
{
"add": {
"body": "Commit '${{ github.event.head_commit.id }}' was added to this issue: ${{ github.event.head_commit.message }}"
}
}
]
}
}' \
--data "{\"update\": {\"comment\": [{\"add\": {\"body\": \"Commit '$COMMIT_ID' was added to this issue: $COMMIT_MSG\"}}]}}" \
-H "Content-Type: application/json" \
"${{ secrets.JIRA_BASEURL }}/rest/api/2/issue/$JIRA_ISSUE_KEY"
env:
Expand Down

0 comments on commit daccc0a

Please sign in to comment.