Update create-jira-issue.yml #70
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: | | |
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 }} \ | |
-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 }} |