Skip to content

chore(Robot): add auto approve action - #1021

Merged
ArgoZhang merged 1 commit into
masterfrom
chore-approve
Jun 15, 2026
Merged

chore(Robot): add auto approve action#1021
ArgoZhang merged 1 commit into
masterfrom
chore-approve

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Jun 15, 2026

Copy link
Copy Markdown
Member

Link issues

fixes #1020

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

CI:

  • Introduce an auto-approve workflow that reviews and approves non-draft PRs from a specified trusted author using a GitHub App token.

Copilot AI review requested due to automatic review settings June 15, 2026 02:28
@bb-auto bb-auto Bot added the chore label Jun 15, 2026
@bb-auto bb-auto Bot added this to the v10.0.0 milestone Jun 15, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a GitHub Actions workflow that automatically approves non-draft pull requests from a specific trusted bot/user using a GitHub App token and the GitHub CLI.

Sequence diagram for auto-approve GitHub Action workflow

sequenceDiagram
    participant PR as PullRequest
    participant GH as GitHubActions
    participant App as GitHubApp(actions/create-github-app-token)
    participant CLI as GitHubCLI(gh)

    PR->>GH: pull_request opened/reopened/synchronize/ready_for_review
    GH->>GH: Check branches master/main
    GH->>GH: [pull_request.draft == false]
    GH->>GH: [user.login in [ArgoZhang]]
    GH->>App: actions/create-github-app-token
    App-->>GH: bb-auto token
    GH->>CLI: gh pr review --approve
    CLI-->>PR: Approval with body Auto approved by bb-auto
Loading

File-Level Changes

Change Details Files
Introduce an auto-approval GitHub Actions workflow for trusted PR authors.
  • Create a new workflow triggered on pull_request events (opened, reopened, synchronize, ready_for_review) targeting main and master branches.
  • Restrict auto-approval to non-draft PRs authored by a specific trusted account using an if condition on the job.
  • Generate a GitHub App installation token via actions/create-github-app-token, configured with stored app ID and private key secrets.
  • Invoke the GitHub CLI gh pr review command with the generated token to submit an approval review comment automatically.
.github/workflows/auto-approve.yml

Assessment against linked issues

Issue Objective Addressed Explanation
#1020 Add a GitHub Actions workflow that automatically approves qualifying pull requests (auto approve action) for this repository.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit 5a4f233 into master Jun 15, 2026
4 checks passed
@ArgoZhang
ArgoZhang deleted the chore-approve branch June 15, 2026 02:29
@ArgoZhang
ArgoZhang restored the chore-approve branch June 15, 2026 02:29

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • The trusted author list is hard-coded in the workflow; consider moving it to a reusable input (e.g., a JSON org/repo variable or secret) so additional maintainers can be added without changing the workflow file.
  • The workflow currently triggers on all PRs to master/main that meet the conditions; if you only want to auto-approve specific types of changes (e.g., label-based or path-based), consider adding an extra condition (such as a required label) to make the auto-approval criteria more explicit and safer.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The trusted author list is hard-coded in the workflow; consider moving it to a reusable input (e.g., a JSON org/repo variable or secret) so additional maintainers can be added without changing the workflow file.
- The workflow currently triggers on all PRs to master/main that meet the conditions; if you only want to auto-approve specific types of changes (e.g., label-based or path-based), consider adding an extra condition (such as a required label) to make the auto-approval criteria more explicit and safer.

## Individual Comments

### Comment 1
<location path=".github/workflows/auto-approve.yml" line_range="11-14" />
<code_context>
+      - synchronize
+      - ready_for_review
+
+jobs:
+  auto_approve:
+    name: auto approve
+    runs-on: ubuntu-latest
+    # Only auto-approve PRs from trusted authors; add accounts to the list as needed
+    if: |
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Lock down workflow permissions explicitly instead of relying on defaults.

Please add an explicit `permissions` block (either at the workflow or job level) to restrict the default `GITHUB_TOKEN` to the minimum required scopes, e.g. `permissions: contents: read`. This limits the blast radius if future steps are added or changed.

```suggestion
      - synchronize
      - ready_for_review

permissions:
  contents: read
  pull-requests: write

jobs:
```
</issue_to_address>

### Comment 2
<location path=".github/workflows/auto-approve.yml" line_range="24-26" />
<code_context>
+      contains(fromJSON('["ArgoZhang"]'), github.event.pull_request.user.login)
+
+    steps:
+      - name: Generate bb-auto token
+        id: app-token
+        uses: actions/create-github-app-token@v2
+        with:
+          app-id: ${{ secrets.BB_AUTO_APP_ID }}
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Pin the GitHub Action to a specific commit SHA instead of a floating major tag.

`@v2` will automatically pick up new v2 releases, which can change behavior unexpectedly and increases supply‑chain risk. Please pin this action to a specific commit SHA (optionally with a comment noting the version) so changes are explicit and reviewable.

Suggested implementation:

```
      - name: Generate bb-auto token
        id: app-token
        # Pin to a specific commit SHA to avoid floating tags (update SHA as needed)
        uses: actions/create-github-app-token@<COMMIT-SHA> # v2.x.x
        with:

```

1. Replace `<COMMIT-SHA>` with the actual commit SHA from the `actions/create-github-app-token` repository corresponding to the desired v2 release.
2. Optionally update `# v2.x.x` to the actual version (e.g. `# v2.0.0`) to make it clear which release you pinned to.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +11 to +14
- synchronize
- ready_for_review

jobs:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Lock down workflow permissions explicitly instead of relying on defaults.

Please add an explicit permissions block (either at the workflow or job level) to restrict the default GITHUB_TOKEN to the minimum required scopes, e.g. permissions: contents: read. This limits the blast radius if future steps are added or changed.

Suggested change
- synchronize
- ready_for_review
jobs:
- synchronize
- ready_for_review
permissions:
contents: read
pull-requests: write
jobs:

Comment on lines +24 to +26
- name: Generate bb-auto token
id: app-token
uses: actions/create-github-app-token@v2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Pin the GitHub Action to a specific commit SHA instead of a floating major tag.

@v2 will automatically pick up new v2 releases, which can change behavior unexpectedly and increases supply‑chain risk. Please pin this action to a specific commit SHA (optionally with a comment noting the version) so changes are explicit and reviewable.

Suggested implementation:

      - name: Generate bb-auto token
        id: app-token
        # Pin to a specific commit SHA to avoid floating tags (update SHA as needed)
        uses: actions/create-github-app-token@<COMMIT-SHA> # v2.x.x
        with:

  1. Replace <COMMIT-SHA> with the actual commit SHA from the actions/create-github-app-token repository corresponding to the desired v2 release.
  2. Optionally update # v2.x.x to the actual version (e.g. # v2.0.0) to make it clear which release you pinned to.

@ArgoZhang
ArgoZhang deleted the chore-approve branch June 15, 2026 02:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GitHub Actions workflow to automatically approve certain non-draft pull requests from a trusted author, aligning with the “Robot” automation goal described in issue #1020.

Changes:

  • Introduces a new auto-approve.yml workflow triggered on pull request events to master/main.
  • Generates a GitHub App installation token and uses gh pr review --approve to submit an approval.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +21
# Only auto-approve PRs from trusted authors; add accounts to the list as needed
if: |
github.event.pull_request.draft == false &&
contains(fromJSON('["ArgoZhang"]'), github.event.pull_request.user.login)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(Robot): add auto approve action

2 participants