Add new game: Doodle Halloween #7
Workflow file for this run
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 Linked Issue When PR is Closed | |
on: | |
pull_request: | |
types: | |
- closed | |
jobs: | |
close-linked-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get linked issue from PR | |
id: get-issue | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
REPO=${{ github.repository }} | |
# Ensure the PR has a linked issue by looking for the 'Linked issues' section | |
# The 'Linked issues' should appear under 'pull_request' body metadata | |
if [[ -z "${{ github.event.pull_request.body }}" ]]; then | |
echo "No linked issue found." | |
exit 0 | |
fi | |
# Check if the PR's body contains an issue reference like "#123" | |
ISSUE_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -oE '#[0-9]+' | head -1 | tr -d '#') | |
if [[ -z "$ISSUE_NUMBER" ]]; then | |
echo "No linked issue found." | |
exit 0 | |
fi | |
echo "issue=$ISSUE_NUMBER" >> $GITHUB_ENV | |
- name: Close the linked issue | |
if: env.issue != '' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ISSUE_NUMBER=${{ env.issue }} | |
REPO=${{ github.repository }} | |
# Close the issue with "not planned" reason | |
gh api -X PATCH repos/$REPO/issues/$ISSUE_NUMBER -f state="closed" -f state_reason="not_planned" -H "Authorization: Bearer $GITHUB_TOKEN" | |
# Add a comment to the issue | |
gh api repos/$REPO/issues/$ISSUE_NUMBER/comments -f body="This game is not eligible to be added. If you think this is a mistake, please review the details and create a new issue instead." -H "Authorization: Bearer $GITHUB_TOKEN" |