This repository has been archived by the owner on Dec 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #7438 from vercel/update-workflow
Auto-close workflow
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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 }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Auto Lock Stale Discussions | ||
# lock discussions that have not been updated in 30 days, | ||
# starting with oldest, and running once per day | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' # Runs every day at midnight UTC | ||
|
||
jobs: | ||
close_discussion: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: get-stale-discussions | ||
id: get-stale-discussions | ||
run: | | ||
staleDiscussionsQuery="repo:amyegan/community-test updated:<$(date -d "-30days" -I) sort:updated-asc is:unlocked" | ||
discussions=$(gh api graphql -F searchQuery="$staleDiscussionsQuery" -f query=' | ||
query oldDiscussions($searchQuery: String!) { | ||
search(query:$searchQuery, type:DISCUSSION, first: 20) { | ||
nodes { | ||
... on Discussion { | ||
id | ||
locked | ||
url | ||
} | ||
} | ||
} | ||
} | ||
' --jq '.data.search.nodes') | ||
echo "DISCUSSIONS_TO_LOCK=$discussions" >> $GITHUB_ENV | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: lock-discussions | ||
run: | | ||
echo "$DISCUSSIONS_TO_LOCK" | jq -r '"Closing \(length) stale discussions: "' | ||
for id in $(jq -r '.[].id' <<< "$DISCUSSIONS_TO_LOCK") | ||
do | ||
lockSucceeded="$(gh api graphql -F discussionId=$id -f query=' | ||
mutation lock($discussionId:ID!) { | ||
lockLockable(input: {lockableId:$discussionId}) { | ||
actor { | ||
login | ||
} | ||
lockedRecord { | ||
activeLockReason | ||
locked | ||
} | ||
} | ||
} | ||
' --jq '.data.lockLockable.lockedRecord.locked')" | ||
echo "Locked $id: $lockSucceeded" | ||
done | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |