- Notifications
You must be signed in to change notification settings - Fork36
GitHub Action that locks closed issues, pull requests and discussions after a period of inactivity
License
dessant/lock-threads
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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 possiblethanks to the support of awesome backers. If you'd like to join them,please consider contributing withPatreon,PayPal orBitcoin.
Create thelock-threads.yml
workflow file in the.github/workflows
directory, use one of theexample workflows to get started.
The action can be configured usinginput parameters.
github-token
- GitHub access token, value must be
${{ github.token }}
or an encryptedsecret that contains apersonal access token - Optional, defaults to
${{ github.token }}
- GitHub access token, value must be
issue-inactive-days
- Number of days of inactivity before a closed issue is locked
- Optional, defaults to
365
exclude-issue-created-before
- Do not lock issues created before a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-created-between
is set - Optional, defaults to
''
- Do not lock issues created before a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-created-after
- Do not lock issues created after a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-created-between
is set - Optional, defaults to
''
- Do not lock issues created after a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-created-between
- Do not lock issues created in a given time interval,value must follow ISO 8601
- Optional, defaults to
''
exclude-issue-closed-before
- Do not lock issues closed before a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-closed-between
is set - Optional, defaults to
''
- Do not lock issues closed before a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-closed-after
- Do not lock issues closed after a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-closed-between
is set - Optional, defaults to
''
- Do not lock issues closed after a given date,value must follow ISO 8601, ignoredwhen
exclude-issue-closed-between
- Do not lock issues closed in a given time interval,value must follow ISO 8601
- Optional, defaults to
''
include-any-issue-labels
- Only lock issues with any of these labels, value must bea comma separated list of labels or
''
, ignoredwheninclude-all-issue-labels
is set - Optional, defaults to
''
- Only lock issues with any of these labels, value must bea comma separated list of labels or
include-all-issue-labels
- Only lock issues with all these labels, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Only lock issues with all these labels, value must bea comma separated list of labels or
exclude-any-issue-labels
- Do not lock issues with any of these labels, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Do not lock issues with any of these labels, value must bea comma separated list of labels or
add-issue-labels
- Labels to add before locking an issue, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Labels to add before locking an issue, value must bea comma separated list of labels or
remove-issue-labels
- Labels to remove before locking an issue, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Labels to remove before locking an issue, value must bea comma separated list of labels or
issue-comment
- Comment to post before locking an issue
- Optional, defaults to
''
issue-lock-reason
- Reason for locking an issue, value must be oneof
resolved
,off-topic
,too heated
,spam
or''
- Optional, defaults to
resolved
- Reason for locking an issue, value must be oneof
pr-inactive-days
- Number of days of inactivity before a closed pull request is locked
- Optional, defaults to
365
exclude-pr-created-before
- Do not lock pull requests created before a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-created-between
is set - Optional, defaults to
''
- Do not lock pull requests created before a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-created-after
- Do not lock pull requests created after a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-created-between
is set - Optional, defaults to
''
- Do not lock pull requests created after a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-created-between
- Do not lock pull requests created in a given time interval,value must follow ISO 8601
- Optional, defaults to
''
exclude-pr-closed-before
- Do not lock pull requests closed before a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-closed-between
is set - Optional, defaults to
''
- Do not lock pull requests closed before a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-closed-after
- Do not lock pull requests closed after a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-closed-between
is set - Optional, defaults to
''
- Do not lock pull requests closed after a given date,value must follow ISO 8601, ignoredwhen
exclude-pr-closed-between
- Do not lock pull requests closed in a given time interval,value must follow ISO 8601
- Optional, defaults to
''
include-any-pr-labels
- Only lock pull requests with any of these labels, value must bea comma separated list of labels or
''
, ignoredwheninclude-all-pr-labels
is set - Optional, defaults to
''
- Only lock pull requests with any of these labels, value must bea comma separated list of labels or
include-all-pr-labels
- Only lock pull requests with all these labels, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Only lock pull requests with all these labels, value must bea comma separated list of labels or
exclude-any-pr-labels
- Do not lock pull requests with any of these labels, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Do not lock pull requests with any of these labels, value must bea comma separated list of labels or
add-pr-labels
- Labels to add before locking a pull request, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Labels to add before locking a pull request, value must bea comma separated list of labels or
remove-pr-labels
- Labels to remove before locking a pull request, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Labels to remove before locking a pull request, value must bea comma separated list of labels or
pr-comment
- Comment to post before locking a pull request
- Optional, defaults to
''
pr-lock-reason
- Reason for locking a pull request, value must be oneof
resolved
,off-topic
,too heated
,spam
or''
- Optional, defaults to
resolved
- Reason for locking a pull request, value must be oneof
discussion-inactive-days
- Number of days of inactivity before a closed discussion is locked
- Optional, defaults to
365
exclude-discussion-created-before
- Do not lock discussions created before a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-created-between
is set - Optional, defaults to
''
- Do not lock discussions created before a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-created-after
- Do not lock discussions created after a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-created-between
is set - Optional, defaults to
''
- Do not lock discussions created after a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-created-between
- Do not lock discussions created in a given time interval,value must follow ISO 8601
- Optional, defaults to
''
exclude-discussion-closed-before
- Do not lock discussions closed before a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-closed-between
is set - Optional, defaults to
''
- Do not lock discussions closed before a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-closed-after
- Do not lock discussions closed after a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-closed-between
is set - Optional, defaults to
''
- Do not lock discussions closed after a given date,value must follow ISO 8601, ignoredwhen
exclude-discussion-closed-between
- Do not lock discussions closed in a given time interval,value must follow ISO 8601
- Optional, defaults to
''
include-any-discussion-labels
- Only lock discussions with any of these labels, value must bea comma separated list of labels or
''
, ignoredwheninclude-all-discussion-labels
is set - Optional, defaults to
''
- Only lock discussions with any of these labels, value must bea comma separated list of labels or
include-all-discussion-labels
- Only lock discussions with all these labels, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Only lock discussions with all these labels, value must bea comma separated list of labels or
exclude-any-discussion-labels
- Do not lock discussions with any of these labels, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Do not lock discussions with any of these labels, value must bea comma separated list of labels or
add-discussion-labels
- Labels to add before locking a discussion, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Labels to add before locking a discussion, value must bea comma separated list of labels or
remove-discussion-labels
- Labels to remove before locking a discussion, value must bea comma separated list of labels or
''
- Optional, defaults to
''
- Labels to remove before locking a discussion, value must bea comma separated list of labels or
discussion-comment
- Comment to post before locking a discussion
- Optional, defaults to
''
process-only
- Only lock issues, pull requests or discussions,value must be a comma separated list, list items must beone of
issues
,prs
ordiscussions
- Optional, defaults to
''
- Only lock issues, pull requests or discussions,value must be a comma separated list, list items must beone of
log-output
- Log output parameters, value must be either
true
orfalse
- Optional, defaults to
false
- Log output parameters, value must be either
issues
- Issues that have been locked, value is a JSON string in the formof
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
- Defaults to
''
- Issues that have been locked, value is a JSON string in the formof
prs
- Pull requests that have been locked, value is a JSON string in the formof
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
- Defaults to
''
- Pull requests that have been locked, value is a JSON string in the formof
discussions
- Discussions that have been locked, value is a JSON string in the formof
[{"owner": "actions", "repo": "toolkit", "discussion_number": 1}]
- Defaults to
''
- Discussions that have been locked, value is a JSON string in the formof
The following workflow will search once an hour for closed issues,pull requests and discussions that have not had any activityin the past year and can be locked.
name:'Lock Threads'on:schedule: -cron:'0 * * * *'workflow_dispatch:permissions:issues:writepull-requests:writediscussions:writeconcurrency:group:lock-threadsjobs:action:runs-on:ubuntu-lateststeps: -uses:dessant/lock-threads@v5
Edit the workflow after the initial backlog of issues, pull requestsand 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 actionand their default values. Any of the parameters can be omitted.
name:'Lock Threads'on:schedule: -cron:'0 0 * * *'workflow_dispatch:permissions:issues:writepull-requests:writediscussions:writeconcurrency:group:lock-threadsjobs:action:runs-on:ubuntu-lateststeps: -uses:dessant/lock-threads@v5with: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 thehelp wanted
orupstream
labels applied.
steps: -uses:dessant/lock-threads@v5with: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 thosewith thewip
label applied.
steps: -uses:dessant/lock-threads@v5with: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@v5with: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 theincomplete
orinvalid
labels applied, and pull requests that have theqa: done
andpublished
labels applied.
steps: -uses:dessant/lock-threads@v5with: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 activityin the past 180 days, and have theqa: verified
label applied.
steps: -uses:dessant/lock-threads@v5with: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 theoutdated
label to issues.
steps: -uses:dessant/lock-threads@v5with: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 theqa: done
andarchived
labels,and remove theqa: primary
andneeds: user feedback
labelsbefore locking issues.
steps: -uses:dessant/lock-threads@v5with: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 actionsas a GitHub user instead of thegithub-actions
app.
Create apersonal access tokenwith therepo
orpublic_repo
scopes enabled, and add the token as anencrypted secretfor the repository or organization, then provide the action with the secretusing thegithub-token
input parameter.
steps: -uses:dessant/lock-threads@v5with:github-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}
The action uses GitHub'supdatedsearch qualifier to determine inactivity. Any change to an issue, pull requestor discussion is considered an update, including new comments,or changing labels.
An easy way to see which threads will initially be locked is to addtheupdated
search qualifier to the issue, pull request or discussionsearch field for your repository, adjust the date based on the valueof the*-inactive-days
input parameter:is:closed is:unlocked updated:<2018-12-20
.
To avoid triggering abuse prevention mechanisms on GitHub, only 50 threadswill 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 theLICENSE file for further information.
About
GitHub Action that locks closed issues, pull requests and discussions after a period of inactivity