Update create-jira-issue.yml #67
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
name: Sync GitHub Actions with Jira | |
on: | |
push: | |
branches: | |
- '*' | |
jobs: | |
sync_with_jira: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Sync commits with Jira | |
run: | | |
JIRA_ISSUE_KEY=$(extract_issue_key_from_commit_message "${{ github.event.head_commit.message }}") | |
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 '$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 }} \ | |
-X POST \ | |
--data '{ | |
"update": { | |
"comment": [ | |
{ | |
"add": { | |
"body": "Commit '${{ github.event.head_commit.id }}' was added to this issue: ${{ github.event.head_commit.message }}" | |
} | |
} | |
] | |
} | |
}' \ | |
-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 }} |