-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1621 from elementary-data/close_pylon_issue
Added close pylon issue workflow
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Close Pylon Ticket on Issue or Pull Request Closure | ||
|
||
on: | ||
issues: | ||
types: [closed] | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
close_pylon_ticket: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Extract Pylon Ticket ID | ||
id: extract_ticket_id | ||
run: | | ||
if [[ "${{ github.event_name }}" == 'issues' ]]; then | ||
ISSUE_BODY=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}" | jq -r '.body') | ||
pylon_ticket_id=$(echo "$ISSUE_BODY" | grep -oP '(?<=<!-- pylon-ticket-id: )\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b(?= -->)') | ||
elif [[ "${{ github.event_name }}" == 'pull_request' ]]; then | ||
PR_BODY=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq -r '.body') | ||
pylon_ticket_id=$(echo "$PR_BODY" | grep -oP '(?<=<!-- pylon-ticket-id: )\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b(?= -->)') | ||
fi | ||
echo "::set-output name=pylon_ticket_id::$pylon_ticket_id" | ||
|
||
- name: Close Pylon Ticket | ||
if: steps.extract_ticket_id.outputs.pylon_ticket_id != '' | ||
run: | | ||
pylon_ticket_id=${{ steps.extract_ticket_id.outputs.pylon_ticket_id }} | ||
echo "Closing Pylon Ticket ID: $pylon_ticket_id" | ||
curl --request PATCH \ | ||
--url "https://api.usepylon.com/issues/$pylon_ticket_id" \ | ||
--header "Authorization: ${{ secrets.PYLON_API_KEY }}" \ | ||
--header 'Content-Type: application/json' \ | ||
--data '{ | ||
"state": "closed" | ||
}' |