Skip to content

Commit da85ff2

Browse files
fix(bots): address review — author bot-guard, engine-repo-scoped token, reviewer concurrency
Three low-severity review findings (all verified real against the branch): - engineer-bot.yml: add `github.event.sender.type != 'Bot'` to the author `if:`, matching the followup gate — defense-in-depth since a GitHub App with `issues: write` could apply the trigger label without a human. - bot-prelude: derive owner/name from the `engine-repo` input for the engine-scoped token mint instead of hardcoding databricks/databricks-bot-engine, so the overridable input is honored (a fork/rename gets a correctly-scoped token rather than a confusing auth failure). - reviewer-bot.yml: add a `concurrency:` group (cancel-in-progress) so rapid pushes to a PR collapse to one review run, matching the other three workflows. Co-authored-by: Isaac Signed-off-by: eric-wang-1990 <e.wang@databricks.com>
1 parent 92f6af9 commit da85ff2

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

.github/actions/bot-prelude/action.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ runs:
4949
app-id: ${{ inputs.app-id }}
5050
private-key: ${{ inputs.private-key }}
5151

52+
# Split `engine-repo` (owner/name) so the token mint below is scoped to the
53+
# SAME repo `install-bot-engine` clones. Deriving it (rather than hardcoding
54+
# databricks/databricks-bot-engine) keeps the overridable `engine-repo` input
55+
# honest: a fork/renamed engine gets a correctly-scoped token instead of an
56+
# auth failure against the wrong repo.
57+
- name: Derive engine repo owner/name
58+
id: engine-scope
59+
shell: bash
60+
env:
61+
ENGINE_REPO: ${{ inputs.engine-repo }}
62+
run: |
63+
echo "owner=${ENGINE_REPO%%/*}" >> "$GITHUB_OUTPUT"
64+
echo "repo=${ENGINE_REPO##*/}" >> "$GITHUB_OUTPUT"
65+
5266
# Engine-scoped token: a SECOND, per-run token scoped to ONLY the engine repo
5367
# (contents:read), used to `pip install` the private engine with no stored
5468
# PAT. Requires the same App installed on the engine repo with contents:read.
@@ -58,8 +72,8 @@ runs:
5872
with:
5973
app-id: ${{ inputs.app-id }}
6074
private-key: ${{ inputs.private-key }}
61-
owner: databricks
62-
repositories: databricks-bot-engine
75+
owner: ${{ steps.engine-scope.outputs.owner }}
76+
repositories: ${{ steps.engine-scope.outputs.repo }}
6377
permission-contents: read
6478

6579
- name: Setup Node (for the Claude Code CLI the SDK spawns)

.github/workflows/engineer-bot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ jobs:
3737
author:
3838
# Manual dispatch, OR the `engineer-bot` label was just applied. Applying a
3939
# label requires triage+ on the repo, so this is the maintainer-only gate.
40+
# The `sender.type != 'Bot'` guard is defense-in-depth (matching the followup
41+
# gate): a GitHub App with `issues: write` could apply the label without a
42+
# human, so the triage+ argument doesn't fully cover automation.
4043
if: >-
4144
github.event_name == 'workflow_dispatch'
42-
|| github.event.label.name == 'engineer-bot'
45+
|| (github.event.label.name == 'engineer-bot'
46+
&& github.event.sender.type != 'Bot')
4347
environment: azure-prod # DATABRICKS_HOST / DATABRICKS_TOKEN live here
4448
runs-on:
4549
group: databricks-protected-runner-group

.github/workflows/reviewer-bot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ jobs:
4444
github.event_name == 'workflow_dispatch'
4545
|| (github.event.pull_request.draft == false
4646
&& github.event.pull_request.head.repo.fork == false)
47+
# Collapse redundant reviews: this triggers on every `synchronize` (push to a
48+
# PR), so rapid pushes would otherwise spawn overlapping runs against the same
49+
# PR. cancel-in-progress: true — a review of a superseded head is wasted work
50+
# (unlike the followups, which use cancel-in-progress: false to avoid dropping
51+
# a reconcile mid-thread). Matches the sibling workflows' concurrency pattern.
52+
concurrency:
53+
group: reviewer-bot-pr-${{ github.event.pull_request.number || inputs.pr_number }}
54+
cancel-in-progress: true
4755
environment: azure-prod # DATABRICKS_HOST / DATABRICKS_TOKEN live here
4856
runs-on:
4957
group: databricks-protected-runner-group

0 commit comments

Comments
 (0)