Skip to content

ci: use the shared Dependabot auto-merge gate - #15061

Merged
loks0n merged 3 commits into
mainfrom
ci/dependabot-shared-gate
Oct 28, 2026
Merged

loks0n merged 3 commits into
mainfrom
ci/dependabot-shared-gate

Conversation

@loks0n

@loks0n loks0n commented Oct 28, 2026

Copy link
Copy Markdown
Member

Replaces this repo's dependabot-auto-merge.yml with a call to the shared workflow from appwrite/.github#132, pinned to its merge commit.

The shared gate runs after each workflow a PR triggers, from the default branch, so a PR can't change it. For a Dependabot patch or minor update it waits for every workflow run, check run and commit status on the exact head SHA, approves when all of them pass, and merges with --match-head-commit. Majors and failures stay for a human. Because it merges directly, the repo doesn't need Allow auto-merge or required status checks.

Part of fixing Dependabot auto-merge across both orgs: 0 bot merges in 30 days, 266 open PRs.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tenki-reviewer

tenki-reviewer Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review complete. 🟡 1 medium

💬 Inline comments (1)


The change rewrites .github/workflows/dependabot-auto-merge.yml: the trigger moves from pull_request to workflow_run for the CI, CodeQL, Console CI, and SDK Preview workflows, permissions move to top-level contents: write / pull-requests: write, and the approval/merge logic is delegated to the appwrite/.github/.github/workflows/dependabot-auto-merge.yml reusable workflow at a pinned SHA.

Files Change
.github/workflows/dependabot-auto-merge.yml Switch to workflow_run trigger, delegate approval/merge to a pinned appwrite/.github reusable workflow, grant top-level write permissions.

The previous local dependabot[bot] actor check and fetch-metadata validation were removed; all gating now lives in the external reusable workflow, leaving this workflow one upstream regression away from merging unintended PRs with write access (see finding-001).

Reviewed commit: 21c3c44

@hansi-codes

hansi-codes Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Tier S · Ready to merge

The new suppression matches the pinned workflow’s behavior, and I found no actionable issues in the changes under review.

Replaces the repository-local Dependabot auto-merge logic with a call to a pinned shared workflow. The gate runs after the configured workflows complete and approves and merges eligible patch or minor updates only after checks pass on the exact PR head SHA.

Latest changes: The newest commit adds a zizmor suppression to the workflow_run trigger, documenting that the pinned shared workflow does not execute pull request code.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 1
File Change
.github/workflows/dependabot-auto-merge.yml Replaces local auto-merge steps with a pinned shared gate, triggered on completion of the configured workflows with the permissions it requires; adds a zizmor suppression documenting the trusted workflow_run setup.

Reviewed the commits since 76b03ea · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Tier B · 1 blocking finding to address. Summary

@tenki-reviewer tenki-reviewer 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.

This PR replaces the local Dependabot auto-merge gating with a delegated reusable workflow, but grants write permissions to every matching workflow_run with no local safety check.

Key findings

Comment on lines +15 to +23
permissions:
checks: read
contents: write
pull-requests: write
statuses: read

jobs:
auto-merge:
if: github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# Auto-merge only waits for checks the base branch requires, so skip it until every gate below is required.
- name: Check required status checks on the base branch
id: protection
run: |
required=$( {
gh api "repos/$REPOSITORY/branches/$BASE" --jq '.protection.required_status_checks.contexts // [] | .[]'
gh api "repos/$REPOSITORY/rules/branches/$BASE" --jq '.[] | select(.type == "required_status_checks") | .parameters.required_status_checks[].context'
} )
missing=""
for check in CI Console CodeQL Hansi; do
grep -qxF "$check" <<< "$required" || missing="$missing $check"
done
if [ -z "$missing" ]; then
echo "required=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::$BASE does not require:$missing. Auto-merge is not enabled."
fi
env:
REPOSITORY: ${{ github.repository }}
BASE: ${{ github.event.pull_request.base.ref }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Enable auto-merge for patch and minor updates
if: steps.protection.outputs.required == 'true' && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor')
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dependabot:
uses: appwrite/.github/.github/workflows/dependabot-auto-merge.yml@d559a62c510dc7eccf274dda83b0a42f89b0bc06 # main

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 security · medium

Grant contents: write on workflow_run with no local gate

The workflow now grants contents: write and pull-requests: write at the top level while the trigger changed from pull_request to workflow_run, which fires for any PR that runs the listed workflows — including untrusted fork PRs — and also for non-PR runs (.github/workflows/dependabot-auto-merge.yml:15-23). The previous version checked github.event.pull_request.user.login == 'dependabot[bot]' and verified Dependabot metadata with dependabot/fetch-metadata locally before acting; all of that gating now lives in a remote reusable workflow that this repository cannot review. If that external gate ever resolves the wrong PR, accepts a non-Dependabot actor, or acts on a failed/cancelled run, the error executes with write access to this repo's contents and pull requests. Impact: code/merge manipulation of protected branches becomes one external-workflow regression away.

📋 Prompt for AI Agents

In .github/workflows/dependabot-auto-merge.yml, the dependabot job (lines 22-23) runs for every completed workflow_run of CI/CodeQL/Console/SDK Preview and holds contents: write + pull-requests: write (lines 15-19), with all safety checks delegated to appwrite/.github@d559a62. Add defense-in-depth in this repo: a job-level if (or a guard job before the uses: call) that verifies the triggering PR is authored by dependabot[bot] — e.g. resolve github.event.workflow_run.pull_requests[0].number via the API and check the author — and only then call the reusable workflow. Also verify the pinned reusable workflow (1) maps workflow_run.head_sha to the associated PR via the API (the event carries no pull_request object), (2) rejects non-Dependabot actors and non-success conclusions, (3) merges with gh pr merge --auto rather than a direct merge, and (4) is idempotent under concurrent invocations (multiple listed workflows completing near-simultaneously each fire this trigger; add a concurrency group keyed on the head SHA if not).

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

The shared gate lists the commit's workflow runs, which needs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → ci/dependabot-shared-gate (after).

Metric Before After Change
🚀 Requests/sec 184.83 177.82 ⚪ -3.8%
⏱️ Latency P50 91.72 ms 98.32 ms 🔴 +7.2%
⏱️ Latency P95 219.95 ms 226.21 ms ⚪ +2.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 98.32 226.21 11,400 177.82 +6.26
Account 179.63 355.05 600 10.12 +17.69
TablesDB 93.83 175.14 6,200 100.29 +9.1
Storage 93.35 210.59 3,000 49.96 -5.06
Functions 136.91 265.5 1,600 27.3 +7.73

Top API waits (after)

API request Max wait (ms)
account.name.update 644.17
functions.delete 569.88
account.prefs.update 493.46
tablesdb.rows.create 429.38
functions.variables.update 417.95

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@hansi-codes hansi-codes Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@loks0n
loks0n merged commit 32ce47e into main Oct 28, 2026
30 checks passed
@loks0n
loks0n deleted the ci/dependabot-shared-gate branch October 28, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant