Giter Site home page Giter Site logo

dessant / repo-lockdown Goto Github PK

View Code? Open in Web Editor NEW
132.0 6.0 15.0 993 KB

GitHub Action that immediately closes and locks issues and pull requests

Home Page: https://github.com/marketplace/actions/repo-lockdown

License: MIT License

JavaScript 100.00%
issues pull-requests close lock mirror fork github-actions

repo-lockdown's Introduction

Repo Lockdown

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.

Supporting the Project

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.

Usage

Create the repo-lockdown.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 }}
  • exclude-issue-created-before
    • Do not process issues created before a given timestamp, value must follow ISO 8601
    • Optional, defaults to ''
  • exclude-issue-labels
    • Do not process issues with any of these labels, value must be a comma separated list of labels
    • Optional, defaults to ''
  • issue-labels
    • Labels to add before closing or locking an issue, value must be a comma separated list of labels
    • Optional, defaults to ''
  • issue-comment
    • Comment to post before closing or locking an issue
    • Optional, defaults to ''
  • skip-closed-issue-comment
    • Do not comment on already closed issues before locking, value must be either true or false
    • Optional, defaults to false
  • close-issue
    • Close issues, value must be either true or false
    • Optional, defaults to true
  • issue-close-reason
    • Reason for closing an issue, value must be either completed or not planned
    • Optional, defaults to not planned
  • lock-issue
    • Lock issues, value must be either true or false
    • Optional, defaults to true
  • issue-lock-reason
    • Reason for locking an issue, value must be one of resolved, off-topic, too heated or spam
    • Optional, defaults to ''
  • exclude-pr-created-before
    • Do not process pull requests created before a given timestamp, value must follow ISO 8601
    • Optional, defaults to ''
  • exclude-pr-labels
    • Do not process pull requests with any of these labels, value must be a comma separated list of labels
    • Optional, defaults to ''
  • pr-labels
    • Labels to add before closing or locking a pull request, value must be a comma separated list of labels
    • Optional, defaults to ''
  • pr-comment
    • Comment to post before closing or locking a pull request
    • Optional, defaults to ''
  • skip-closed-pr-comment
    • Do not comment on already closed pull requests before locking, value must be either true or false
    • Optional, defaults to false
  • close-pr
    • Close pull requests, value must be either true or false
    • Optional, defaults to true
  • lock-pr
    • Lock pull requests, value must be either true or false
    • Optional, defaults to true
  • pr-lock-reason
    • Reason for locking a pull request, value must be one of resolved, off-topic, too heated or spam
    • Optional, defaults to ''
  • process-only
    • Process only issues or pull requests, value must be either issues or prs
    • 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 closed or 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 closed or 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 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

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

Excluding issues and pull requests

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'

Commenting and labeling

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.

Reducing notification spam while commenting

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

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

Why are only some issues and pull requests processed?

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.

License

Copyright (c) 2019-2023 Armin Sebastian

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

repo-lockdown's People

Contributors

dessant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

repo-lockdown's Issues

Error: HttpError: Resource not accessible by integration

I have included repo-lockdown in my project. My goal is to automatically close all the PR with a message. I tested this exact same file in a private repo to check that it was working as expected and it worked. Now, in a real repository, when I go to Actions in github, it shows:

Run dessant/repo-lockdown@v2
  with:
    github-token: ***
    skip-closed-issue-comment: false
    close-issue: false
    lock-issue: true
    pr-comment: cpufetch does not accept pull requests, see [the contributing guidelines](https://github.com/Dr-Noob/cpufetch/blob/master/CONTRIBUTING.md) for details
    skip-closed-pr-comment: false
    close-pr: true
    lock-pr: false
    process-only: prs
Error: HttpError: Resource not accessible by integration

What is happening?

Comment only on open pull requests and issues, not closed ones

Amazing app! I have only one comment. I know there is skipCreatedBefore to set what to process, but I would prefer that all issues and pull requests are closed/locked, but only on those which were initially open a comment is left. Would that be possible?

Org-wide config?

Hi

The PostgreSQL project has been using the legacy app to close PRs to all the mirror repos we keep on Github (https://github.com/postgres). I noticed today that the we've had a couple of PRs that haven't been closed, and realised after digging in that you've moved the project to use Github Actions, and deprecated the old Probot app.

For various reasons it's not feasible for us to add a .github directory to the upstream source trees. Are there any plans to support org-wide configuration as we used to use?

Deprecation message for legacy app

Hi!

Repo Lockdown has been rewritten for GitHub Actions, offering new features and better control over your automation presets. The legacy GitHub App has been deprecated, and the public instance of the app has been shut down. You're receiving this message because the deprecated app is still installed for your user account or organization.

You can follow the user guide and examples to install the new action for your repositories:

https://github.com/dessant/repo-lockdown

If you need any help with configuring the action, please open an issue or message me at [email protected].

The continued development of Repo Lockdown is made possible thanks to the support of awesome backers. If you'd like to join them, please check out https://github.com/sponsors/dessant

Please ignore the new permission request for the app, it was only used to notify project maintainers directly, without opening thousands of issues.

Thanks,
Armin Sebastian

feat: exclude lockdown by user

It'd be nice to have an exclusion list that can be by username. For example: Only members of the GitHub organization can be allowed to create new issues. This can be part of an exclusion list of usernames. Anyone else not in this list will be subject to the repo-lockdown action.

Node.js 12 actions are deprecated; The `set-output` command is deprecated

action
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: dessant/repo-lockdown

action
The set-output command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.