|
1 | 1 | <h3 align="center"> |
2 | 2 | <img alt="transparent" src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/misc/transparent.png" height="30" width="0px"/> |
3 | | - bfra.me GitHub App Template |
| 3 | + Auto-Approval Bot |
4 | 4 | <img alt="transparent" src="https://raw.githubusercontent.com/catppuccin/catppuccin/main/assets/misc/transparent.png" height="30" width="0px"/> |
5 | 5 | </h3> |
6 | 6 |
|
7 | 7 | <p align="center"> |
8 | 8 | <a href="https://github.com/bfra-me/github-app/actions?query=workflow%3Aci" title="Search GitHub Actions for CI workflow runs" ><img alt="GitHub Workflow CI Status" src="https://img.shields.io/github/actions/workflow/status/bfra-me/github-app/ci.yaml?branch=main&style=for-the-badge&logo=github%20actions&logoColor=white&label=ci"></a> |
9 | 9 | </p> |
10 | 10 |
|
11 | | -> This repository is an example of how to create a GitHub Action using Probot |
| 11 | +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. |
| 12 | + |
| 13 | +## Features |
| 14 | + |
| 15 | +- Automatically approves PRs from configured bot users |
| 16 | +- Configurable approval triggers in PR bodies |
| 17 | +- Option to require all checks to pass before approval |
| 18 | +- Specify particular checks that must pass for approval |
| 19 | +- Exclude PRs with specific labels from auto-approval |
| 20 | +- Re-approves PRs when approvals are dismissed |
| 21 | +- Works as a GitHub App or GitHub Action |
| 22 | +- Fully tested and follows best practices |
| 23 | + |
| 24 | +## Configuration |
| 25 | + |
| 26 | +Create a `.github/auto-approve.yml` (or `.yaml`) with the following options: |
| 27 | + |
| 28 | +```yaml |
| 29 | +# Bot usernames whose PRs should be auto-approved |
| 30 | +botUsernames: |
| 31 | + - renovate[bot] |
| 32 | + - dependabot[bot] |
| 33 | + - mend-for-github-com[bot] |
| 34 | + |
| 35 | +# Phrases in PR body that indicate the PR should be auto-approved |
| 36 | +approvalTriggers: |
| 37 | + - "**Automerge**: Enabled" |
| 38 | + |
| 39 | +# Whether to require all checks to pass before approving |
| 40 | +requirePassingChecks: true |
| 41 | + |
| 42 | +# Specific checks that must pass for auto-approval (if empty and requirePassingChecks is true, all checks must pass) |
| 43 | +requiredChecks: |
| 44 | + - build |
| 45 | + - test |
| 46 | + |
| 47 | +# Labels that will prevent auto-approval if present on the PR |
| 48 | +excludeLabels: |
| 49 | + - do-not-merge |
| 50 | + - wip |
| 51 | +``` |
| 52 | +
|
| 53 | +## Usage |
| 54 | +
|
| 55 | +### As a GitHub Action |
| 56 | +
|
| 57 | +Create a workflow file (e.g., `.github/workflows/auto-approve.yaml`): |
| 58 | + |
| 59 | +```yaml |
| 60 | +name: Auto Approve |
| 61 | +
|
| 62 | +on: |
| 63 | + pull_request: |
| 64 | + types: [opened, reopened, synchronize, labeled, edited] |
| 65 | + pull_request_review: |
| 66 | + types: [dismissed] |
| 67 | + check_run: |
| 68 | + types: [completed] |
| 69 | +
|
| 70 | +permissions: |
| 71 | + contents: read |
| 72 | + pull-requests: write |
| 73 | + checks: read |
| 74 | +
|
| 75 | +jobs: |
| 76 | + auto-approve: |
| 77 | + runs-on: ubuntu-latest |
| 78 | + name: Auto Approve PRs |
| 79 | + steps: |
| 80 | + - uses: bfra-me/github-app@v1 |
| 81 | + with: |
| 82 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + # Optional: path to config file |
| 84 | + config-path: .github/auto-approve.yml |
| 85 | +``` |
| 86 | + |
| 87 | +### As a Deployed App |
| 88 | + |
| 89 | +You can deploy this app as a GitHub App on platforms like Vercel: |
| 90 | + |
| 91 | +1. Create a GitHub App in your organization or account |
| 92 | +2. Set the required permissions: |
| 93 | + - Pull requests: Read & Write |
| 94 | + - Checks: Read |
| 95 | + - Repository contents: Read |
| 96 | + - Repository metadata: Read |
| 97 | +3. Subscribe to the webhook events: |
| 98 | + - Pull request |
| 99 | + - Pull request review |
| 100 | + - Check run |
| 101 | +4. Deploy to a serverless platform like Vercel: |
| 102 | + ```bash |
| 103 | + # Install Vercel CLI |
| 104 | + npm i -g vercel |
| 105 | +
|
| 106 | + # Deploy |
| 107 | + vercel |
| 108 | + ``` |
| 109 | + |
| 110 | +5. Set the webhook URL to your deployment URL |
| 111 | + |
| 112 | +## Development |
| 113 | + |
| 114 | +```bash |
| 115 | +# Install dependencies |
| 116 | +pnpm install |
| 117 | +
|
| 118 | +# Run in development mode |
| 119 | +pnpm run dev |
| 120 | +
|
| 121 | +# Build |
| 122 | +pnpm run build |
| 123 | +
|
| 124 | +# Run tests |
| 125 | +pnpm test |
| 126 | +
|
| 127 | +# Type checking |
| 128 | +pnpm run typecheck |
| 129 | +
|
| 130 | +# Linting |
| 131 | +pnpm run lint |
| 132 | +
|
| 133 | +# Format code |
| 134 | +pnpm run format |
| 135 | +``` |
12 | 136 |
|
13 | 137 | ## License |
14 | 138 |
|
|
0 commit comments