From 54cc8365f1d3ca3e3f326a5b9172910a830ec4b0 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 17 Oct 2025 15:27:30 +0200 Subject: [PATCH] Revert fe3adf9 (#5107) --- .github/workflows/discussion_lock.yml | 105 -------------------------- 1 file changed, 105 deletions(-) delete mode 100644 .github/workflows/discussion_lock.yml diff --git a/.github/workflows/discussion_lock.yml b/.github/workflows/discussion_lock.yml deleted file mode 100644 index 3dd2b20a..00000000 --- a/.github/workflows/discussion_lock.yml +++ /dev/null @@ -1,105 +0,0 @@ -name: discussion_lock -on: - schedule: - - cron: '40 16 * * *' - workflow_dispatch: - -jobs: - discussion_lock: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/github-script@v8 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const { repo: { owner, repo } } = context; - const now = new Date(); - const twoYearsAgo = new Date(now.getTime() - 1000*60*60*24*365*2); - - const query = ` - query($owner: String!, $repo: String!, $cursor: String) { - repository(owner: $owner, name: $repo) { - discussions(first: 100, after: $cursor, filterBy: {locked: false}) { - pageInfo { - hasNextPage - endCursor - } - nodes { - id - number - title - closed - closedAt - updatedAt - category { - isAnswerable - } - answer { - id - } - } - } - } - } - `; - - let hasNextPage = true; - let cursor = null; - - while (hasNextPage) { - const result = await github.graphql(query, { - owner, - repo, - cursor - }); - - const discussions = result.repository.discussions; - hasNextPage = discussions.pageInfo.hasNextPage; - cursor = discussions.pageInfo.endCursor; - - for (const discussion of discussions.nodes) { - const lastUpdateDate = new Date(discussion.updatedAt); - const closedDate = discussion.closedAt ? new Date(discussion.closedAt) : null; - const relevantDate = closedDate || lastUpdateDate; - - if (relevantDate > twoYearsAgo) { - continue; - } - - const addCommentMutation = ` - mutation($discussionId: ID!, $body: String!) { - addDiscussionComment(input: {discussionId: $discussionId, body: $body}) { - comment { - id - } - } - } - `; - - await github.graphql(addCommentMutation, { - discussionId: discussion.id, - body: `This discussion is being locked automatically because the last update was more than 2 years ago.\n`+ - `\n`+ - `**Do not use the content of this discussion as reference since it's probably outdated!**\n`+ - `\n`+ - `The official documentation is the only place in which you can find up-to-date answers.\n`, - }); - - const lockMutation = ` - mutation($discussionId: ID!) { - lockLockable(input: {lockableId: $discussionId}) { - lockedRecord { - locked - } - } - } - `; - - await github.graphql(lockMutation, { - discussionId: discussion.id - }); - - process.exit(0); - } - }