Lock Threads is a GitHub Action that locks closed issues, pull requests and discussions after a period of inactivity.
The continued development of Lock Threads is made possible thanks to the support of awesome backers. If you'd like to join them, please consider contributing with Patreon, PayPal or Bitcoin.
Create the lock-threads.yml
workflow file in the .github/workflows
directory, use one of the example workflows to get started.
The action can be configured using input parameters.
github-token
${{ github.token }}
or an encrypted
secret that contains a personal access token${{ github.token }}
issue-inactive-days
365
exclude-issue-created-before
exclude-issue-created-between
is set''
exclude-issue-created-after
exclude-issue-created-between
is set''
exclude-issue-created-between
''
exclude-issue-closed-before
exclude-issue-closed-between
is set''
exclude-issue-closed-after
exclude-issue-closed-between
is set''
exclude-issue-closed-between
''
include-any-issue-labels
''
, ignored
when include-all-issue-labels
is set''
include-all-issue-labels
''
''
exclude-any-issue-labels
''
''
add-issue-labels
''
''
remove-issue-labels
''
''
issue-comment
''
issue-lock-reason
resolved
, off-topic
, too heated
, spam
or ''
resolved
pr-inactive-days
365
exclude-pr-created-before
exclude-pr-created-between
is set''
exclude-pr-created-after
exclude-pr-created-between
is set''
exclude-pr-created-between
''
exclude-pr-closed-before
exclude-pr-closed-between
is set''
exclude-pr-closed-after
exclude-pr-closed-between
is set''
exclude-pr-closed-between
''
include-any-pr-labels
''
, ignored
when include-all-pr-labels
is set''
include-all-pr-labels
''
''
exclude-any-pr-labels
''
''
add-pr-labels
''
''
remove-pr-labels
''
''
pr-comment
''
pr-lock-reason
resolved
, off-topic
, too heated
, spam
or ''
resolved
discussion-inactive-days
365
exclude-discussion-created-before
exclude-discussion-created-between
is set''
exclude-discussion-created-after
exclude-discussion-created-between
is set''
exclude-discussion-created-between
''
exclude-discussion-closed-before
exclude-discussion-closed-between
is set''
exclude-discussion-closed-after
exclude-discussion-closed-between
is set''
exclude-discussion-closed-between
''
include-any-discussion-labels
''
, ignored
when include-all-discussion-labels
is set''
include-all-discussion-labels
''
''
exclude-any-discussion-labels
''
''
add-discussion-labels
''
''
remove-discussion-labels
''
''
discussion-comment
''
process-only
issues
, prs
or discussions
''
log-output
true
or false
false
issues
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
''
prs
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
''
discussions
[{"owner": "actions", "repo": "toolkit", "discussion_number": 1}]
''
The following workflow will search once an hour for closed issues, pull requests and discussions that have not had any activity in the past year and can be locked.
name: 'Lock Threads'
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
permissions:
issues: write
pull-requests: write
discussions: write
concurrency:
group: lock-threads
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
Edit the workflow after the initial backlog of issues, pull requests and discussions has been processed to reduce the frequency of scheduled runs. Running the workflow only once a day helps reduce resource usage.
on:
schedule:
- cron: '0 0 * * *'
This workflow declares all the available input parameters of the action and their default values. Any of the parameters can be omitted.
name: 'Lock Threads'
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
issues: write
pull-requests: write
discussions: write
concurrency:
group: lock-threads
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
with:
github-token: ${{ github.token }}
issue-inactive-days: '365'
exclude-issue-created-before: ''
exclude-issue-created-after: ''
exclude-issue-created-between: ''
exclude-issue-closed-before: ''
exclude-issue-closed-after: ''
exclude-issue-closed-between: ''
include-any-issue-labels: ''
include-all-issue-labels: ''
exclude-any-issue-labels: ''
add-issue-labels: ''
remove-issue-labels: ''
issue-comment: ''
issue-lock-reason: 'resolved'
pr-inactive-days: '365'
exclude-pr-created-before: ''
exclude-pr-created-after: ''
exclude-pr-created-between: ''
exclude-pr-closed-before: ''
exclude-pr-closed-after: ''
exclude-pr-closed-between: ''
include-any-pr-labels: ''
include-all-pr-labels: ''
exclude-any-pr-labels: ''
add-pr-labels: ''
remove-pr-labels: ''
pr-comment: ''
pr-lock-reason: 'resolved'
discussion-inactive-days: '365'
exclude-discussion-created-before: ''
exclude-discussion-created-after: ''
exclude-discussion-created-between: ''
exclude-discussion-closed-before: ''
exclude-discussion-closed-after: ''
exclude-discussion-closed-between: ''
include-any-discussion-labels: ''
include-all-discussion-labels: ''
exclude-any-discussion-labels: ''
add-discussion-labels: ''
remove-discussion-labels: ''
discussion-comment: ''
process-only: ''
log-output: false
This step will lock only issues, and exclude issues created before 2018,
or those with the help wanted
or upstream
labels applied.
steps:
- uses: dessant/lock-threads@v5
with:
exclude-issue-created-before: '2018-01-01T00:00:00Z'
exclude-any-issue-labels: 'help wanted, upstream'
process-only: 'issues'
This step will lock only pull requests, and exclude those
with the wip
label applied.
steps:
- uses: dessant/lock-threads@v5
with:
exclude-any-pr-labels: 'wip'
process-only: 'prs'
This step will lock only issues, and exclude issues closed before 2018, or those created in 2018 and 2019.
steps:
- uses: dessant/lock-threads@v5
with:
exclude-issue-created-between: '2018-01-01T00:00:00Z/2019-12-31T23:59:59.999Z'
exclude-issue-closed-before: '2018-01-01T00:00:00Z'
process-only: 'issues'
This step will lock issues that have the incomplete
or invalid
labels applied, and pull requests that have the qa: done
and published
labels applied.
steps:
- uses: dessant/lock-threads@v5
with:
include-any-issue-labels: 'incomplete, invalid'
include-all-pr-labels: 'qa: done, published'
process-only: 'issues, prs'
This step will lock discussions that have not had any activity
in the past 180 days, and have the qa: verified
label applied.
steps:
- uses: dessant/lock-threads@v5
with:
discussion-inactive-days: '180'
include-any-discussion-labels: 'qa: verified'
process-only: 'discussions'
This step will post a comment on issues and pull requests before locking them,
and apply the outdated
label to issues.
steps:
- uses: dessant/lock-threads@v5
with:
add-issue-labels: 'outdated'
issue-comment: >
This issue has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
pr-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
process-only: 'issues, prs'
This step will apply the qa: done
and archived
labels,
and remove the qa: primary
and needs: user feedback
labels
before locking issues.
steps:
- uses: dessant/lock-threads@v5
with:
add-issue-labels: 'qa: done, archived'
remove-issue-labels: 'qa: primary, needs: user feedback'
process-only: 'issues'
The action uses an installation access token by default to interact with GitHub.
You may also authenticate with a personal access token to perform actions
as a GitHub user instead of the github-actions
app.
Create a personal access token
with the repo
or public_repo
scopes enabled, and add the token as an
encrypted secret
for the repository or organization, then provide the action with the secret
using the github-token
input parameter.
steps:
- uses: dessant/lock-threads@v5
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
The action uses GitHub's updated search qualifier to determine inactivity. Any change to an issue, pull request or discussion is considered an update, including new comments, or changing labels.
An easy way to see which threads will initially be locked is to add
the updated
search qualifier to the issue, pull request or discussion
search field for your repository, adjust the date based on the value
of the *-inactive-days
input parameter:
is:closed is:unlocked updated:<2018-12-20
.
To avoid triggering abuse prevention mechanisms on GitHub, only 50 threads will be handled at a time. If your repository has more than that, it will take a few hours or days to process them all.
Copyright (c) 2017-2023 Armin Sebastian
This software is released under the terms of the MIT License. See the LICENSE file for further information.