Close issue #85
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: "Close issue" | |
on: | |
project_card: | |
types: [moved] | |
jobs: | |
close-issue: | |
name: "Close issue when card moves to Done column" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Close issue | |
run: | | |
CARD=$(curl \ | |
-H 'Accept: application/vnd.github.v3+json' \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.inertia-preview+json" \ | |
https://api.github.com/projects/columns/cards/${{ github.event.project_card.id }}) | |
COLUMN_URL=$(echo $CARD | jq -r '.column_url') | |
COLUMN_NAME=$(curl \ | |
-H 'Accept: application/vnd.github.v3+json' \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.inertia-preview+json" \ | |
$COLUMN_URL \ | |
| jq -r '.name') | |
if [[ $COLUMN_NAME == *"Done"* ]]; then | |
ISSUE_URL=$(echo $CARD | jq -r '.content_url') | |
echo "Closing issue: $ISSUE_URL" | |
curl \ | |
-X PATCH \ | |
-H 'Accept: application/vnd.github.v3+json' \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
$ISSUE_URL \ | |
-d '{"state":"closed"}' | |
else | |
echo "Not closing issue as it was moved to column $COLUMN_NAME" | |
fi |