Skip to content
/ github-app Public template
generated from probot/example-github-action

Template repository for a GitHub App that can be triggered by a GitHub Action

License

Notifications You must be signed in to change notification settings

bfra-me/github-app

Repository files navigation

transparent Auto-Approval Bot transparent

GitHub Workflow CI Status

A GitHub App built with Probot that automatically approves pull requests from specific bots with configured trigger phrases. Perfect for handling Renovate, Dependabot or other automated PRs that can be safely merged without manual review.

Features

  • Automatically approves PRs from configured bot users
  • Configurable approval triggers in PR bodies
  • Option to require all checks to pass before approval
  • Specify particular checks that must pass for approval
  • Exclude PRs with specific labels from auto-approval
  • Re-approves PRs when approvals are dismissed
  • Works as a GitHub App or GitHub Action
  • Fully tested and follows best practices

Configuration

Create a .github/auto-approve.yml (or .yaml) with the following options:

# Bot usernames whose PRs should be auto-approved
botUsernames:
  - renovate[bot]
  - dependabot[bot]
  - mend-for-github-com[bot]

# Phrases in PR body that indicate the PR should be auto-approved
approvalTriggers:
  - "**Automerge**: Enabled"

# Whether to require all checks to pass before approving
requirePassingChecks: true

# Specific checks that must pass for auto-approval (if empty and requirePassingChecks is true, all checks must pass)
requiredChecks:
  - build
  - test

# Labels that will prevent auto-approval if present on the PR
excludeLabels:
  - do-not-merge
  - wip

Usage

As a GitHub Action

Create a workflow file (e.g., .github/workflows/auto-approve.yaml):

name: Auto Approve

on:
  pull_request:
    types: [opened, reopened, synchronize, labeled, edited]
  pull_request_review:
    types: [dismissed]
  check_run:
    types: [completed]

permissions:
  contents: read
  pull-requests: write
  checks: read

jobs:
  auto-approve:
    runs-on: ubuntu-latest
    name: Auto Approve PRs
    steps:
      - uses: bfra-me/github-app@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          # Optional: path to config file
          config-path: .github/auto-approve.yml

As a Deployed App

You can deploy this app as a GitHub App on platforms like Vercel:

  1. Create a GitHub App in your organization or account

  2. Set the required permissions:

    • Pull requests: Read & Write
    • Checks: Read
    • Repository contents: Read
    • Repository metadata: Read
  3. Subscribe to the webhook events:

    • Pull request
    • Pull request review
    • Check run
  4. Deploy to a serverless platform like Vercel:

    # Install Vercel CLI
    npm i -g vercel
    
    # Deploy
    vercel
  5. Set the webhook URL to your deployment URL

Development

# Install dependencies
pnpm install

# Run in development mode
pnpm run dev

# Build
pnpm run build

# Run tests
pnpm test

# Type checking
pnpm run typecheck

# Linting
pnpm run lint

# Format code
pnpm run format

License

MIT