Lock Threads is a GitHub Action that locks closed issues and pull requests 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 a lock.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 access token, value must be
${{ github.token }}
or an encrypted secret that contains a personal access token - Optional, defaults to
${{ github.token }}
- GitHub access token, value must be
issue-lock-inactive-days
- Number of days of inactivity before a closed issue is locked
- Optional, defaults to
365
issue-exclude-created-before
- Do not lock issues created before a given timestamp, value must follow ISO 8601
- Optional, defaults to
''
issue-exclude-labels
- Do not lock issues with these labels, value must be
a comma separated list of labels or
''
- Optional, defaults to
''
- Do not lock issues with these labels, value must be
a comma separated list of labels or
issue-lock-labels
- Labels to add before locking an issue, value must be
a comma separated list of labels or
''
- Optional, defaults to
''
- Labels to add before locking an issue, value must be
a comma separated list of labels or
issue-lock-comment
- Comment to post before locking an issue
- Optional, defaults to
''
issue-lock-reason
- Reason for locking an issue, value must be one
of
resolved
,off-topic
,too heated
,spam
or''
- Optional, defaults to
resolved
- Reason for locking an issue, value must be one
of
pr-lock-inactive-days
- Number of days of inactivity before a closed pull request is locked
- Optional, defaults to
365
pr-exclude-created-before
- Do not lock pull requests created before a given timestamp, value must follow ISO 8601
- Optional, defaults to
''
pr-exclude-labels
- Do not lock pull requests with these labels, value must
be a comma separated list of labels or
''
- Optional, defaults to
''
- Do not lock pull requests with these labels, value must
be a comma separated list of labels or
pr-lock-labels
- Labels to add before locking a pull request, value must be
a comma separated list of labels or
''
- Optional, defaults to
''
- Labels to add before locking a pull request, value must be
a comma separated list of labels or
pr-lock-comment
- Comment to post before locking a pull request
- Optional, defaults to
''
pr-lock-reason
- Reason for locking a pull request, value must be one
of
resolved
,off-topic
,too heated
,spam
or''
- Optional, defaults to
resolved
- Reason for locking a pull request, value must be one
of
process-only
- Limit locking to only issues or pull requests, value must be
one of
issues
,prs
or''
- Optional, defaults to
''
- Limit locking to only issues or pull requests, value must be
one of
issues
- Issues that have been locked, value is a JSON string in the form
of
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
- Defaults to
''
- Issues that have been locked, value is a JSON string in the form
of
prs
- Pull requests that have been locked, value is a JSON string in the form
of
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
- Defaults to
''
- Pull requests that have been locked, value is a JSON string in the form
of
The following workflow will search once an hour for closed issues and pull requests that can be locked.
name: 'Lock Threads'
on:
schedule:
- cron: '0 * * * *'
permissions:
issues: write
pull-requests: write
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
Edit the workflow after the initial backlog of issues and pull requests 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 * * *'
permissions:
issues: write
pull-requests: write
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: '365'
issue-exclude-created-before: ''
issue-exclude-labels: ''
issue-lock-labels: ''
issue-lock-comment: ''
issue-lock-reason: 'resolved'
pr-lock-inactive-days: '365'
pr-exclude-created-before: ''
pr-exclude-labels: ''
pr-lock-labels: ''
pr-lock-comment: ''
pr-lock-reason: 'resolved'
process-only: ''
This step will lock only issues, and exclude issues created before 2018,
or those with the upstream
or help-wanted
labels applied.
steps:
- uses: dessant/lock-threads@v2
with:
issue-exclude-created-before: '2018-01-01T00:00:00Z'
issue-exclude-labels: 'upstream, help-wanted'
process-only: 'issues'
This step will lock only pull requests, and exclude those
with the wip
label applied.
steps:
- uses: dessant/lock-threads@v2
with:
pr-exclude-labels: 'wip'
process-only: 'prs'
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@v2
with:
issue-lock-labels: 'outdated'
issue-lock-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-lock-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.
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@v2
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
The action uses GitHub's updated search qualifier to determine inactivity. Any change to an issue or pull request is considered an update, including comments, changing labels, applying or removing milestones, or pushing commits.
An easy way to check and see which issues or pull requests will initially
be locked is to add the updated
search qualifier to either the issue
or pull request page filter for your repository:
is:closed is:unlocked updated:<2018-12-20
.
Adjust the date to be 365 days ago (or whatever you set for *-lock-inactive-days
)
to see which issues or pull requests will be locked.
To avoid triggering abuse prevention mechanisms on GitHub, only 50 issues and pull requests will be handled at once. If your repository has more than that, it will just take a few hours or days to process them all.
Copyright (c) 2017-2021 Armin Sebastian
This software is released under the terms of the MIT License. See the LICENSE file for further information.