GitHub Action that immediately closes and locks issues and pull requests
Repo Lockdown is a GitHub Action that immediately closes and locks issues and pull requests. It is mainly used with repositories that do not accept issues or pull requests, such as forks and mirrors.
The continued development of Repo Lockdown 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 repo-lockdown.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 }}
exclude-issue-created-before
''
exclude-issue-labels
''
issue-labels
''
issue-comment
''
skip-closed-issue-comment
true
or false
false
close-issue
true
or false
true
issue-close-reason
completed
or not planned
not planned
lock-issue
true
or false
true
issue-lock-reason
resolved
, off-topic
, too heated
or spam
''
exclude-pr-created-before
''
exclude-pr-labels
''
pr-labels
''
pr-comment
''
skip-closed-pr-comment
true
or false
false
close-pr
true
or false
true
lock-pr
true
or false
true
pr-lock-reason
resolved
, off-topic
, too heated
or spam
''
process-only
issues
or prs
''
log-output
true
or false
false
issues
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
''
prs
[{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
''
The following workflow will search once an hour for existing issues and pull requests that can be closed or locked. New issues and pull requests will be immediately processed when they are opened.
name: 'Repo Lockdown'
on:
issues:
types: opened
pull_request_target:
types: opened
schedule:
- cron: '0 * * * *'
permissions:
issues: write
pull-requests: write
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/repo-lockdown@v4
Scheduled runs are no longer needed once the initial backlog
of issues and pull requests has been processed. It's best to edit
the workflow after the backlog has been processed and remove
the schedule
event to avoid unnecessary workflow runs.
on:
issues:
types: opened
pull_request_target:
types: opened
This workflow declares all the available input parameters of the action and their default values. Any of the parameters can be omitted.
name: 'Repo Lockdown'
on:
issues:
types: opened
pull_request_target:
types: opened
schedule:
- cron: '0 * * * *'
permissions:
issues: write
pull-requests: write
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/repo-lockdown@v4
with:
github-token: ${{ github.token }}
exclude-issue-created-before: ''
exclude-issue-labels: ''
issue-labels: ''
issue-comment: ''
skip-closed-issue-comment: false
close-issue: true
issue-close-reason: 'not planned'
lock-issue: true
issue-lock-reason: ''
exclude-pr-created-before: ''
exclude-pr-labels: ''
pr-labels: ''
pr-comment: ''
skip-closed-pr-comment: false
close-pr: true
lock-pr: true
pr-lock-reason: ''
process-only: ''
log-output: false
This step will close and lock only issues, and exclude issues created
before 2018, or those with the pinned
or help-wanted
labels applied.
steps:
- uses: dessant/repo-lockdown@v4
with:
exclude-issue-created-before: '2018-01-01T00:00:00Z'
exclude-issue-labels: 'pinned, help-wanted'
process-only: 'issues'
This step will close only pull requests, and exclude those
with the pinned
label applied.
steps:
- uses: dessant/repo-lockdown@v4
with:
exclude-pr-labels: 'pinned'
lock-pr: false
process-only: 'prs'
This step will post a comment on issues and pull requests before
closing and locking them, and will apply the off-topic
label to issues.
steps:
- uses: dessant/repo-lockdown@v4
with:
issue-labels: 'off-topic'
issue-comment: >
This repository does not accept bug reports,
see the README for details.
pr-comment: >
This repository does not accept pull requests,
see the README for details.
Informing the participants of issues and pull requests before locking discussions can help redirect contributors to the right place to continue their work, though it may be useful to avoid posting comments on already closed issues and pull requests to reduce notification spam.
This step will post a comment on open issues and pull requests before closing and locking them, and will avoid commenting on threads that have already been closed before locking them.
steps:
- uses: dessant/repo-lockdown@v4
with:
issue-comment: >
This repository does not accept bug reports,
see the README for details.
skip-closed-issue-comment: true
pr-comment: >
This repository does not accept pull requests,
see the README for details.
skip-closed-pr-comment: true
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/repo-lockdown@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
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) 2019-2023 Armin Sebastian
This software is released under the terms of the MIT License. See the LICENSE file for further information.