GitHub Action
Inactivity Lock
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.
- Lock Issues & Pull Requests: Locks issues and pull requests after a certain period of inactivity.
- Custom Lock Reasons: Set custom lock reasons for issues and pull requests.
- Rate Limit Buffer: Set a rate limit buffer to prevent rate limit issues.
- Detailed Error Messages: Provides clear error messages when something goes wrong.
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.
The GitHub token used to interact with the GitHub API.
- Default:
${{ github.token }}
- Usage: Optional
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
.
- default:
100
- Usage: Optional
The number of days an issue should be inactive before it gets locked.
- default:
90
- Usage: Optional
The number of days a pull request should be inactive before it gets locked.
- default:
90
- Usage: Optional
The reason that will be used to lock the issues. Valid reasons are: off-topic
, too heated
, resolved
, spam
, ""
.
- default:
resolved
- Usage: Optional
The reason that will be used to lock the pull requests. Valid reasons are: off-topic
, too heated
, resolved
, spam
, ""
.
- default:
resolved
- Usage: Optional
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" }
]
A list of issues that have been locked.
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.