Skip to content
31 changes: 31 additions & 0 deletions .github/workflows/jira-advance-to-qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Advance Jira Ticket to QA

on:
pull_request_review:
types: [ submitted ]

permissions: {}

jobs:
advance:
name: Move linked Jira ticket to QA
runs-on: ubuntu-latest
# Public repo: anyone can approve, and a fork branch can be named after
# anyone's ticket. Only our own branches, approved by someone with write access.
if: >-
github.event.review.state == 'approved' &&
github.event.pull_request.head.repo.full_name == github.repository &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
steps:
- name: Move the ticket to QA
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
AUTH: ${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}
run: |
KEY=$(echo "$BRANCH" | grep -oE 'ADFA-[0-9]+' | head -1)
[ -n "$KEY" ] || { echo "No ADFA key in $BRANCH"; exit 0; }
API="https://appdevforall.atlassian.net/rest/api/3/issue/$KEY/transitions"
ID=$(curl -sf -u "$AUTH" "$API" | jq -r '.transitions[] | select(.to.name == "QA") | .id')
[ -n "$ID" ] || { echo "$KEY offers no transition to QA"; exit 0; }
curl -sf -u "$AUTH" -X POST -H 'Content-Type: application/json' \
-d "{\"transition\":{\"id\":\"$ID\"}}" "$API" && echo "$KEY -> QA"
Loading