Skip to content

ci: auto-open and auto-approve management API types sync PRs - #627

Merged
Rodriguespn merged 1 commit into
mainfrom
Rodriguespn/auto-sync-approve-mgmt-api-types
Nov 26, 2026
Merged

Rodriguespn merged 1 commit into
mainfrom
Rodriguespn/auto-sync-approve-mgmt-api-types

Conversation

@Rodriguespn

@Rodriguespn Rodriguespn commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Auto-opens the Management API types sync PR whenever Check Management API Types fails, and auto-approves + auto-merges it once Tests pass. Follows the same supabase-oss pattern team CLI uses in bot-pr-auto-merge.yml and CODEOWNERS.

  • Triggers sync-management-api-types.yml on failed Check Management API Types workflow_run completions, serialized with a sync-management-api-types concurrency group. Existing chore/regenerate-management-api-types PRs are updated in place (or skipped as a no-op if unchanged).
  • Adds @supabase-oss alongside @supabase/ai in .github/CODEOWNERS only for the two generated types.ts files (management-api/types.ts and management-api-v2/types.ts).
  • Adds auto-approve-management-api-types.yml, triggered on Tests workflow_run success in main's context (never checks out PR code). Validates same repo, main target, non-draft, supabase-releaser[bot], exact HEAD SHA, and 1–2 modified files strictly within those two types.ts paths before approving via AUTO_APPROVE_PR_PAT and enabling/executing squash auto-merge.
flowchart TD
    T1["PR fails Check Management API Types"] --> SYNC
    T2["Daily cron 06:00 UTC"] --> SYNC
    T3["Manual workflow_dispatch"] --> SYNC

    SYNC["sync-management-api-types.yml\n(runs on main, serialized by concurrency)"] --> OPEN{"PR already open on\nchore/regenerate-management-api-types?"}

    OPEN -->|No| PR["Opens PR as supabase-releaser[bot]"]
    OPEN -->|Yes, same spec diff| NOOP["Clean no-op\n(no push, no duplicate PR)"]
    OPEN -->|Yes, newer spec diff| PR2["Force-pushes updated commit\nto existing PR in place"]

    PR --> CI1["Code Quality (biome.yml)\nrequired on main"]
    PR --> CI2["Tests (tests.yml)\nbuild + typecheck + vitest + ui-test"]
    PR2 --> CI1
    PR2 --> CI2

    CI2 -->|fails: e.g. breaking OpenAPI change| STOP1["Stops: PR stays open,\nno approval, no merge"]
    CI2 -->|succeeds| AA["auto-approve-management-api-types.yml\n(runs on main, never checks out PR code)"]

    AA --> GATE{"Strict gates:\n• same repo + main target + non-draft\n• actor == sender == supabase-releaser[bot]\n• HEAD SHA matches Tests run\n• only 1-2 modified types.ts files (no renames)"}

    GATE -->|any check fails| STOP2["Aborts: no approval, no merge"]
    GATE -->|all pass| APP["supabase-oss approves exact HEAD SHA\n(satisfies CODEOWNERS on types.ts only)"]

    APP --> AM{"Repo allow_auto_merge?"}
    AM -->|false| HOLD["Approved only — human merges"]
    AM -->|true| MERGE["Squash-merges at exact HEAD SHA\n(immediately if CLEAN, or waits for Code Quality)"]
Loading

Repo prerequisites are already configured (main-restricted auto-approve environment with AUTO_APPROVE_PR_PAT, supabase-oss write access, allow_auto_merge=true). Verified with actionlint + shellcheck and by running the file-allowlist script against #609 and negative fixtures (extra file, rename, added file).

@Rodriguespn
Rodriguespn requested a review from a team as a code owner November 26, 2026 13:10
@coveralls

coveralls commented Nov 26, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 45827700551

Coverage increased (+0.001%) to 98.267%

Details

  • Coverage increased (+0.001%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 6717
Covered Lines: 6636
Line Coverage: 98.79%
Relevant Branches: 1475
Covered Branches: 1414
Branch Coverage: 95.86%
Branches in Coverage %: Yes
Coverage Strength: 2335.18 hits per line

💛 - Coveralls

- Trigger sync-management-api-types.yml on failed Check Management API Types runs with a concurrency group
- Add narrow CODEOWNERS entries for the two generated management-api types.ts files with @supabase-oss
- Add auto-approve-management-api-types.yml to approve and enable auto-merge after Tests pass on verified bot PRs
@Rodriguespn
Rodriguespn force-pushed the Rodriguespn/auto-sync-approve-mgmt-api-types branch from 4839eac to 39099cb Compare November 26, 2026 13:17

@barryroodt barryroodt 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.

nice!

@Rodriguespn
Rodriguespn merged commit 7f84b80 into main Nov 26, 2026
11 of 12 checks passed
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.

3 participants