Discussions close on PR merge (#2336)

This commit is contained in:
Real-MullaC 2024-07-13 17:00:37 +01:00 committed by GitHub
parent 84242db2db
commit bdb60b0b44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View File

@ -24,6 +24,8 @@
## Issue related to PR ## Issue related to PR
[What issue is related to this PR (if any)] [What issue is related to this PR (if any)]
- Resolves # - Resolves #
[What discussion is related to this PR (if any)]
- Discussion: #
## Additional Information ## Additional Information
[Any additional information that reviewers should be aware of.] [Any additional information that reviewers should be aware of.]

30
.github/workflows/close-discussion.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: Close Discussion on PR Merge
on:
pull_request:
types: [closed]
jobs:
closeDiscussion:
runs-on: ubuntu-latest
steps:
- name: Check if PR was merged
if: github.event.pull_request.merged == true
run: echo "PR was merged"
- name: Extract Discussion Number
if: github.event.pull_request.merged == true
id: extract-discussion
run: |
echo "::set-output name=discussion::$(echo "${{ github.event.pull_request.body }}" | grep -oP '(?<=Discussion: #)\d+')"
shell: bash
- name: Close the discussion
if: github.event.pull_request.merged == true && steps.extract-discussion.outputs.discussion
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DISCUSSION_ID: ${{ steps.extract-discussion.outputs.discussion }}
run: |
curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \
-d '{"state": "closed"}' \
"https://api.github.com/repos/${{ github.repository }}/discussions/${DISCUSSION_ID}"