Skip to content

Commit 0768ad4

Browse files
committed
chore: CI: Jira sync
1 parent c545e7b commit 0768ad4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/jira.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Jira sync
2+
3+
on:
4+
issues:
5+
types: [closed]
6+
7+
jobs:
8+
jira-sync:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Move Jira issue to Done
13+
env:
14+
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
15+
JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }}
16+
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
17+
run: |
18+
issue_number=${{ github.event.issue.number }}
19+
20+
jira_issue_key=$(curl -s -u "${JIRA_USERNAME}:${JIRA_API_TOKEN}" \
21+
-X GET -H "Content-Type: application/json" \
22+
"${JIRA_BASE_URL}/rest/api/2/search?jql=summary~\"${issue_number}\"" | \
23+
jq -r '.issues[0].key')
24+
25+
if [ -z "$jira_issue_key" ]; then
26+
exit
27+
fi
28+
29+
curl -s -u "${JIRA_USERNAME}:${JIRA_API_TOKEN}" \
30+
-X POST -H "Content-Type: application/json" \
31+
--data "{\"transition\": {\"id\": \"41\"}}" \
32+
"${JIRA_BASE_URL}/rest/api/2/issue/${jira_issue_key}/transitions"
33+
34+
echo "Moved Jira issue ${jira_issue_key} to Done"

0 commit comments

Comments
 (0)