This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
New Discussion Auto-lock #155
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: New Discussion Auto-lock | |
# automatically lock and close new discussion posts | |
on: | |
discussion: | |
types: [created] | |
jobs: | |
lock_discussion: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Close and lock discussion | |
run: | | |
lockSucceeded="$(gh api graphql -F discussionId=$DISCUSSION_ID -f query=' | |
mutation lock($discussionId:ID!) { | |
addDiscussionComment(input:{discussionId:$discussionId, body:"This discussion was automatically closed because the community moved to [vercel.community](https://vercel.community)"}) { | |
comment{ | |
url | |
} | |
} | |
closeDiscussion(input: {discussionId:$discussionId, reason: OUTDATED}) { | |
discussion { | |
url | |
stateReason | |
} | |
} | |
lockLockable(input: {lockableId:$discussionId}) { | |
actor { | |
login | |
} | |
lockedRecord { | |
activeLockReason | |
locked | |
} | |
} | |
} | |
' --jq '.data.lockLockable.lockedRecord.locked')" | |
echo "LOCKED =" $lockSucceeded | |
echo '${{ github.event.discussion.number }}' | jq -r '"https://github.com/vercel/community/discussions/\(.)"' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DISCUSSION_ID: ${{ github.event.discussion.node_id }} |