Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

New Discussion Auto-lock #154

New Discussion Auto-lock

New Discussion Auto-lock #154

Workflow file for this run

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 }}