• Stars
    star
    337
  • Rank 125,272 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

πŸ‘ GitHub Action for automatically approving GitHub pull requests

Auto Approve GitHub Action

CI

Name: hmarr/auto-approve-action

Automatically approve GitHub pull requests.

Important: use v3 or later, as v2 uses Node.js 12, which is deprecated. If you're on an old version of GHES (earlier than 3.4) you may need to use v2 until you can upgrade. v1 was designed for the initial GitHub Actions beta, and no longer works.

Usage instructions

Create a workflow file (e.g. .github/workflows/auto-approve.yml) that contains a step that uses: hmarr/auto-approve-action@v3. Here's an example workflow file:

name: Auto approve
on: pull_request_target

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: hmarr/auto-approve-action@v3

Combine with an if clause to only auto-approve certain users. For example, to auto-approve Dependabot pull requests, use:

name: Auto approve

on: pull_request_target

jobs:
  auto-approve:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    if: github.actor == 'dependabot[bot]'
    steps:
      - uses: hmarr/auto-approve-action@v3

If you want to use this action from a workflow file that doesn't run on the pull_request or pull_request_target events, use the pull-request-number input:

name: Auto approve

on:
  workflow_dispatch:
    inputs: pullRequestNumber
      description: Pull request number to auto-approve
      required: false

jobs:
  auto-approve:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
    - uses: hmarr/auto-approve-action@v3
      with:
        pull-request-number: ${{ github.event.inputs.pullRequestNumber }}

Optionally, you can provide a message for the review:

name: Auto approve

on: pull_request_target

jobs:
  auto-approve:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    if: github.actor == 'dependabot[bot]'
    steps:
      - uses: hmarr/auto-approve-action@v3
        with:
          review-message: "Auto approved automated PR"

Approving on behalf of a different user

By default, this will use the automatic GitHub token that's provided to the workflow. This means the approval will come from the "github-actions" bot user. Make sure you enable the pull-requests: write permission in your workflow.

To approve the pull request as a different user, pass a GitHub Personal Access Token into the github-token input. In order to approve the pull request, the token needs the repo scope enabled.

name: Auto approve

on: pull_request_target

jobs:
  auto-approve:
    runs-on: ubuntu-latest
    steps:
      - uses: hmarr/auto-approve-action@v3
        with:
          github-token: ${{ secrets.SOME_USERS_PAT }}

Approving Dependabot pull requests

When a workflow is run in response to a Dependabot pull request using the pull_request event, the workflow won't have access to secrets. If you're trying to use a Personal Access Token (as above) but getting an error on Dependabot pull requests, this is probably why.

Fortunately the fix is simple: use the pull_request_target event instead of pull_request. This runs the workflow in the context of the base branch of the pull request, which does have access to secrets.

Why?

GitHub lets you prevent merges of unapproved pull requests. However, it's occasionally useful to selectively circumvent this restriction - for instance, some people want Dependabot's automated pull requests to not require approval.

Code owners

If you're using a CODEOWNERS file, you'll need to give this action a personal access token for a user listed as a code owner. Rather than using a real user's personal access token, you're probably better off creating a dedicated bot user, and adding it to a team which you assign as the code owner. That way you can restrict the bot user's permissions as much as possible, and your workflow won't break when people leave the team.

Development and release process

Each major version corresponds to a branch (e.g. v2, v3). The latest major version (v3 at the time of writing) is the repository's default branch. Releases are tagged with semver-style version numbers (e.g. v1.2.3).

More Repositories

1

vitals

πŸ“Š A tiny macOS process monitor
Swift
414
star
2

codecube

Docker-powered runnable code snippets
Go
313
star
3

django-mumblr

Mumblr is a basic Django tumblelog application that uses MongoDB.
Python
255
star
4

codeowners

πŸ”’ Command line tool and Go library for CODEOWNERS files
Go
105
star
5

debug-action

πŸ›  Show environment variables and event JSON in the Action logs
JavaScript
105
star
6

django-debug-toolbar-mongo

MongoDB panel for the Django Debug Toolbar
Python
89
star
7

chromesheep

FireSheep for Chrome
CoffeeScript
63
star
8

mongosearch

A proof-of-concept full-text search engine using MongoDB
Python
59
star
9

pick-dom-element

πŸ–± A JavaScript library for interactively picking DOM elements
TypeScript
29
star
10

chrome-cookie-switcher

Switch between website accounts easily in Chrome
JavaScript
17
star
11

dotfiles

πŸ’» @hmarr's dotfiles - mostly vim and zsh configuration
Shell
17
star
12

grephub

πŸ” Search GitHub repositories with regexes
JavaScript
12
star
13

docker-postgresql

Shell
9
star
14

chrome-detect-font

πŸ–‹ Easily see which fonts are in use
TypeScript
8
star
15

ircviewer

A web-based IRC viewer, packed with comety goodness
Python
6
star
16

mortgage-calculator-react

A toy built to try out React
JavaScript
6
star
17

vscode-cel

🎨 VS Code syntax highlighting for CEL
6
star
18

debug-tools

πŸ”§ Docker image with useful debugging tools
Dockerfile
5
star
19

pkgextract

Extract a set of Go packages that depend on one another
Go
5
star
20

alfred-workflow-translate

🎩 Quick access to Google Translate via Alfred
JavaScript
5
star
21

barclays_bikes

A Ruby library for retrieving Barclays Bike availability
Ruby
4
star
22

vim-gemfile

A faster way of adding gems to your Gemfiles
Vim Script
4
star
23

skeema

A Scheme-like language interpreter in C
C
3
star
24

canvaschart

Simple canvas-based javascript charting library
JavaScript
3
star
25

mines

πŸ’£ A substandard implementation of the best game ever
TypeScript
3
star
26

xlsx-to-csv

πŸ’Ύ Convert XLSX files to CSVs
Go
3
star
27

schemacompare

Simple database schema comparison tool
Python
3
star
28

monkey_hunter

Find out what a Ruby library monkey patches
Ruby
3
star
29

gitbook-plugin-numbered-headings

Numbered headings for GitBook PDFs
CSS
2
star
30

tree-sitter-sqlite

🌳 A work-in-progress SQLite grammar for tree-sitter
JavaScript
2
star
31

dotjs

JavaScript
2
star
32

dependawhat

πŸ€– See what Dependabot's up to
TypeScript
2
star
33

barista

β˜•οΈ Keeps your Mac awake while it's on the clock
Go
2
star
34

hack-stack

πŸ’Ύ Software toolchain for the nand2tetris Hack computer
Rust
2
star
35

codecube-ruby

Ruby API client library for codecube.io
Ruby
2
star
36

advisories-analysis

Analysing the GitHub Advisory Database with sqlite and pandas
Jupyter Notebook
2
star
37

docker-pandoc-latex

2
star
38

auto-approve-test

1
star
39

ch

Like chruby, but supports multiple languages
Shell
1
star
40

codeowners-rs

πŸ”’ A fast Rust library and CLI for GitHub's CODEOWNERS files
Rust
1
star
41

serve

πŸ—‚ Serve files from the current directory over HTTP
Go
1
star
42

gemfile-lock-tmlanguage

🎨 A tmLanguage grammar for Bundler's Gemfile.lock files
1
star
43

homebrew-tap

🍺 Homebrew tap for @hmarr's home brewed software
Ruby
1
star
44

yarn-lock-inconsistency

Shell
1
star