Skip to content

marqeta/pr-bot-cli

Repository files navigation

PR-Bot-Cli

Name: marqeta/pr-bot-cli@main

PR Bot Cli is a GitHub Action that automatically approves PRs when user-defined reuqirements are met.

Important: Allow auto-merge must be enabled for PR Bot Cli to work.

How to Use in GitHub Workflow.

GitHub Workflow is a user-configurable automated process to run CI/CD jobs.

It is very easy to use PR Bot Cli in GitHub Workflow.

1. Create Presonal Access Token

To use PR Bot Cli, you would first need to create a GitHub Personal Access Token.

Click on your profile picture at top right corner, go to settings -> developer settings -> personal access token -> fine-grained tokens, click on the generate new token.

Repo read-only and read:org permissions should be enough for PR Bot Cli to work.

Remmeber to copy your personal access token as you woould need to use in the next step.

2. Store Personal Access Token as Repository Secret

Go to your repository, click on settings.

image

Go to Secrets and variables -> actions -> New Repository Secrets. Create a new secret paste your newly created GitHub token as its value, and set its name to PR_BOT_TOKEN.

3. Enable Auto Merge for Repo

Go to settings -> general, enable allow auto-merge.

image

4. Invoke GitHub Action

Create a .github/prbot.yml under root directory of your repository.

name: PR Bot auto approval

on:
  pull_request:

jobs:
  pr-bot:
    runs-on: ubuntu-latest
    steps:
      - name: PR Bot Auto Approval
        uses: marqeta/pr-bot-cli@main
        with:
          github_token: ${{ secrets.PR_BOT_TOKEN }}

4. Create your own policy

Create a .prbot/my_policy/approval.rego and a .prbot/my_policy/filter.rego under root directorty of your repository.

In filter.rego, you could filter out the PRs that you would like PR Bot to review.

In approval.rego, you could specify the condition that PR Bot use to review / approve a PR.

You could find exmaples of PR Bot rego files at here

Example

PR bot automatically approved & merged a PR generated by dependabot for updating JavaScript version. image