From 2390d09f8d065623c3988825d536fed673771cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20de=20Courville?= Date: Wed, 8 Jul 2026 11:43:32 +0200 Subject: [PATCH] Update workflow to close old issues and PRs This PR does two things: 1. Fix the `"githubToken" length must be less than or equal to 100 characters long` error. 2. Make the messages more informative. **For issues:** > This issue has been automatically closed and locked. > > Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository. > > If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at: > https://github.com/processing/processing4/issues/new/choose > > Thank you for helping improve Processing **For PRs:** > This pull request has been automatically closed and locked. > > Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository. > > If you'd still like to contribute this work, please open an issue in the Processing 4 repository to discuss it first: > https://github.com/processing/processing4/issues/new/choose > > Thank you for your contribution. --- .github/workflows/lock.yml | 98 +++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 18 deletions(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index 5ed1e8ee84..914771c1b5 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -1,29 +1,91 @@ -name: 'Lock Threads' +name: Close old issues and pull requests on: schedule: - cron: '0 6 * * *' + workflow_dispatch: permissions: - contents: read + issues: write + pull-requests: write jobs: - lock: - permissions: - issues: write - pull-requests: write + close-old-threads: runs-on: ubuntu-latest + steps: - - uses: dessant/lock-threads@v2.0.1 + - uses: actions/github-script@v9 with: - github-token: ${{ github.token }} - issue-lock-inactive-days: '30' - issue-lock-comment: > - This issue has been automatically locked. To avoid confusion - with reports that have already been resolved, closed issues - are automatically locked 30 days after the last comment. - Please open a new issue for related bugs. - pr-lock-comment: > - This pull request has been automatically locked. - Pull requests that have been closed are automatically - locked 30 days after the last comment. + script: | + const cutoffDays = 30; + const exemptLabels = ['keep-open']; + + const cutoff = new Date(); + cutoff.setDate(cutoff.getDate() - cutoffDays); + + const closeIssueMessage = `This issue has been automatically closed and locked. + + Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository. + + If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at: + https://github.com/processing/processing4/issues/new/choose + + Thank you for helping improve Processing.`; + + const closePrMessage = `This pull request has been automatically closed and locked. + + Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository. + + If you'd still like to contribute this work, please open an issue in the Processing 4 repository to discuss it first: + https://github.com/processing/processing4/issues/new/choose + + Thank you for your contribution.`; + + const threads = await github.paginate(github.rest.issues.listForRepo, { + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + per_page: 100, + sort: 'updated', + direction: 'asc' + }); + + for (const thread of threads) { + const updatedAt = new Date(thread.updated_at); + + if (updatedAt > cutoff) { + continue; + } + + const labels = thread.labels.map(label => label.name); + const isExempt = labels.some(label => exemptLabels.includes(label)); + + if (isExempt) { + continue; + } + + const isPr = Boolean(thread.pull_request); + const body = isPr ? closePrMessage : closeIssueMessage; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: thread.number, + body + }); + + await github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: thread.number, + state: 'closed', + state_reason: 'not_planned' + }); + + await github.rest.issues.lock({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: thread.number, + lock_reason: 'resolved' + }); + }