• Stars
    star
    308
  • Rank 135,068 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GitHub Action that locks closed issues, pull requests and discussions after a period of inactivity

Lock Threads

Lock Threads is a GitHub Action that locks closed issues and pull requests after a period of inactivity.

Supporting the Project

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.

Usage

Create the lock.yml workflow file in the .github/workflows directory, use one of the example workflows to get started.

Inputs

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 }}
  • 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, ignored when exclude-issue-created-between is set
    • Optional, defaults to ''
  • exclude-issue-created-after
    • Do not lock issues created after a given date, value must follow ISO 8601, ignored when exclude-issue-created-between is set
    • Optional, defaults to ''
  • 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, ignored when exclude-issue-closed-between is set
    • Optional, defaults to ''
  • exclude-issue-closed-after
    • Do not lock issues closed after a given date, value must follow ISO 8601, ignored when exclude-issue-closed-between is set
    • Optional, defaults to ''
  • 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 be a comma separated list of labels or '', ignored when include-all-issue-labels is set
    • Optional, defaults to ''
  • include-all-issue-labels
    • Only lock issues with all these labels, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • exclude-any-issue-labels
    • Do not lock issues with any of these labels, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • add-issue-labels
    • Labels to add before locking an issue, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • remove-issue-labels
    • Labels to remove before locking an issue, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • issue-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
  • 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, ignored when exclude-pr-created-between is set
    • Optional, defaults to ''
  • exclude-pr-created-after
    • Do not lock pull requests created after a given date, value must follow ISO 8601, ignored when exclude-pr-created-between is set
    • Optional, defaults to ''
  • 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, ignored when exclude-pr-closed-between is set
    • Optional, defaults to ''
  • exclude-pr-closed-after
    • Do not lock pull requests closed after a given date, value must follow ISO 8601, ignored when exclude-pr-closed-between is set
    • Optional, defaults to ''
  • 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 be a comma separated list of labels or '', ignored when include-all-pr-labels is set
    • Optional, defaults to ''
  • include-all-pr-labels
    • Only lock pull requests with all these labels, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • exclude-any-pr-labels
    • Do not lock pull requests with any of these labels, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • add-pr-labels
    • Labels to add before locking a pull request, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • remove-pr-labels
    • Labels to remove before locking a pull request, value must be a comma separated list of labels or ''
    • Optional, defaults to ''
  • 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 one of resolved, off-topic, too heated, spam or ''
    • Optional, defaults to resolved
  • process-only
    • Limit locking to only issues or pull requests, value must be one of issues, prs or ''
    • Optional, defaults to ''
  • log-output
    • Log output parameters, value must be either true or false
    • Optional, defaults to false

Outputs

  • issues
    • Issues that have been locked, value is a JSON string in the form of [{"owner": "actions", "repo": "toolkit", "issue_number": 1}]
    • Defaults to ''
  • 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 ''

Examples

The following workflow will search once an hour for closed issues and pull requests that have not had any activity in the past year and can be locked.

name: 'Lock Threads'

on:
  schedule:
    - cron: '0 * * * *'
  workflow_dispatch:

permissions:
  issues: write
  pull-requests: write

concurrency:
  group: lock

jobs:
  action:
    runs-on: ubuntu-latest
    steps:
      - uses: dessant/lock-threads@v4

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 * * *'

Available input parameters

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 * * *'
  workflow_dispatch:

permissions:
  issues: write
  pull-requests: write

concurrency:
  group: lock

jobs:
  action:
    runs-on: ubuntu-latest
    steps:
      - uses: dessant/lock-threads@v4
        with:
          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'
          process-only: ''
          log-output: false

Filtering issues and pull requests

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@v4
        with:
          exclude-issue-created-before: '2018-01-01T00:00:00Z'
          exclude-any-issue-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@v4
        with:
          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@v4
        with:
          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 the incomplete or invalid labels applied, and pull requests that have the qa: done and published labels applied.

    steps:
      - uses: dessant/lock-threads@v4
        with:
          include-any-issue-labels: 'incomplete, invalid'
          include-all-pr-labels: 'qa: done, published'

This step will lock issues that have not had any activity in the past 180 days.

    steps:
      - uses: dessant/lock-threads@v4
        with:
          issue-inactive-days: '180'
          process-only: 'issues'

Commenting and labeling

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@v4
        with:
          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.

This step will apply the qa: done and archived labels, and remove the qa: primary and needs: user feedback labels before locking issues.

    steps:
      - uses: dessant/lock-threads@v4
        with:
          add-issue-labels: 'qa: done, archived'
          remove-issue-labels: 'qa: primary, needs: user feedback'

Using a personal access token

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@v4
        with:
          github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

How are issues and pull requests determined to be inactive?

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 search field for your repository: is:closed is:unlocked updated:<2018-12-20. Adjust the date to be 365 days ago (or whatever you set for *-inactive-days) to see which issues or pull requests will be locked.

Why are only some issues and pull requests processed?

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.

License

Copyright (c) 2017-2023 Armin Sebastian

This software is released under the terms of the MIT License. See the LICENSE file for further information.

More Repositories

1

buster

Captcha solver extension for humans, available for Chrome, Edge and Firefox
JavaScript
7,207
star
2

search-by-image

Browser extension for reverse image search, available for Chrome, Edge and Safari
JavaScript
2,044
star
3

web-archives

Browser extension for viewing archived and cached versions of web pages, available for Chrome, Edge and Safari
JavaScript
1,119
star
4

buster-client

User input simulation for Buster
Go
248
star
5

clear-browsing-data

Browser extension for clearing browsing data, available for Chrome, Edge and Firefox
JavaScript
171
star
6

repo-lockdown

GitHub Action that immediately closes and locks issues and pull requests
JavaScript
133
star
7

label-actions

🤖 GitHub Action that performs certain tasks when issues, pull requests or discussions are labeled or unlabeled
JavaScript
111
star
8

issue-states

⚠️ PARTIALLY BROKEN - GitHub Action that closes or reopens issues when they are moved to a project column
JavaScript
83
star
9

youtube-video-quality

Watch YouTube in your preferred video quality
JavaScript
77
star
10

ping-blocker

Stop sites from tracking the links you visit through hyperlink auditing
JavaScript
68
star
11

move-issues

🤖 GitHub App that moves issues between repositories
JavaScript
48
star
12

reaction-comments

👍 📨 💔 GitHub Action that deletes +1 comments
JavaScript
44
star
13

search-google-us

Search Google without being redirected to local search results
JavaScript
34
star
14

support-requests

GitHub Action that comments on and closes issues labeled as support requests
JavaScript
34
star
15

youtube-autoplay

Browser extension that disables autoplay on YouTube
JavaScript
27
star
16

scroll-zoom

Browser extension for zooming web pages with the left or right mouse button and the scroll wheel
JavaScript
25
star
17

lock-threads-app

🤖 GitHub App that locks closed issues and pull requests after a period of inactivity
JavaScript
14
star
18

probot-messages

Probot extension for communicating with repository maintainers
JavaScript
14
star
19

wesa

Storage schema migration for browser extensions
JavaScript
4
star
20

vueton

Vue components
Vue
3
star
21

repo-lockdown-app

🤖 GitHub App that closes and locks new and existing issues or pull requests
JavaScript
3
star
22

support-requests-app

GitHub App that comments on and closes issues labeled as support requests
JavaScript
3
star
23

reaction-comments-app

👍 📨 💔 GitHub App that deletes +1 comments
JavaScript
3
star
24

ext-contribute

Vue
3
star
25

ext-components

Vue
2
star
26

label-actions-app

GitHub App that performs actions when issues or pull requests are labeled or unlabeled
JavaScript
2
star
27

issue-states-app

GitHub App that opens or closes issues when they are moved to a project column
JavaScript
1
star
28

storage-versions

JavaScript
1
star