🔒 GitHub Action to lock inactive issues or pull requests
APACHE-2.0 License
This GitHub action is useful for repositories that want to lock issues and pull requests after a certain period of inactivity, to keep the repository clean and organized.
For fetching the issues and pull requests, the action uses the GraphQL API. Instead of a REST API search call, which is very limited in the number of API calls, with the result that you can quickly encounter a secondary ratelimit error.
name: Lock
on:
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
jobs:
inactivity-lock:
name: Lock issues and PRs
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: 🔒 Lock closed issues and PRs
uses: klaasnicolaas/action-inactivity-lock@v1
with:
days-inactive-issues: 30
days-inactive-prs: 30
lock-reason-issues: ""
lock-reason-prs: ""
The following input parameters can be used to configure the action.
If no input parameters are provided, the action will use the default values.
repo-token
The GitHub token used to interact with the GitHub API.
${{ github.token }}
rate-limit-buffer
The rate limit buffer is to prevent rate limit issues with the GitHub API. GitHub has a rate limit of 5000 requests per hour. The action will stop if the rate limit buffer is reached. for example, if the rate limit buffer is set to 200
, the action will stop when the remaining request reached 200
.
100
days-inactive-issues
The number of days an issue should be inactive before it gets locked.
90
days-inactive-prs
The number of days a pull request should be inactive before it gets locked.
90
lock-reason-issues
The reason that will be used to lock the issues. Valid reasons are: off-topic
, too heated
, resolved
, spam
, ""
.
resolved
lock-reason-prs
The reason that will be used to lock the pull requests. Valid reasons are: off-topic
, too heated
, resolved
, spam
, ""
.
resolved
The following output can be used to display the locked issues and pull requests.
Both outputs are a list of objects with the following structure:
[
{ number: 1, title: "Title" },
{ number: 2, title: "Title" }
]
locked-issues
A list of issues that have been locked.
locked-prs
A list of pull requests that have been locked.
name: Lock
on:
schedule:
- cron: "0 3 * * *"
workflow_dispatch:
jobs:
inactivity-lock:
name: Lock issues and PRs
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: 🔒 Lock closed issues and PRs
uses: klaasnicolaas/action-inactivity-lock@v1
id: lock
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
rate-limit-buffer: 200
days-inactive-issues: 30
days-inactive-prs: 30
lock-reason-issues: "resolved"
lock-reason-prs: "resolved"
- name: 🔍 Display locked issues and PRs
run: |
echo "Locked issues: $(echo '${{ steps.lock.outputs.locked-issues }}' | jq)"
echo "Locked PRs: $(echo '${{ steps.lock.outputs.locked-prs }}' | jq)"
This is an active open-source project. We are always open to people who want to use the code or contribute to it.
We've set up a separate document for our contribution guidelines.
Thank you for being involved! 😍
Distributed under the Apache License 2.0 license. See LICENSE
for more information.