Skip to content

ci(frontend-deploy): Authenticate Vercel deploys with OIDC - #9220

Draft
matthewelwell wants to merge 4 commits into
mainfrom
ci/vercel-deploy-oidc
Draft

matthewelwell wants to merge 4 commits into
mainfrom
ci/vercel-deploy-oidc

Conversation

@matthewelwell

@matthewelwell matthewelwell commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Warning

Blocked: the vercel-cli OIDC app is not enabled for our Vercel team. Team settings offer only VCR and Turborepo CLI policies, and POST /v1/oidc-policies returns 403. Without a policy the exchange yields no token and every frontend deploy fails, so this must not merge until Vercel enable the app for us.

A Vercel access token acts as the user who minted it, so enforcing 2FA on the team gated every call made with a token whose owner had not enrolled. Production and demo share one person's token and both failed with You must set up Two-Factor Authentication before accessing this team; demo2 holds another's and kept deploying.

These three projects deploy from CI rather than through Vercel's Git integration so the E2E suite can gate them, which is what Vercel recommend:

Use this approach when you can't connect a repository through Vercel's Git integration, when you want to run tests before a deployment goes live, or when only build output should leave your pipeline.

So a bearer token is unavoidable — make it a short-lived one. The job now exchanges its GitHub OIDC token for a Vercel access token in a new .github/actions/vercel-login, alongside codeartifact-login. Vercel have no login action for CLI deploys yet, so the exchange lives there and swaps out in one line when they ship one.

This needs an OIDC policy on the team first, or the exchange matches nothing. One policy for all three projects, so no exchange is ambiguous:

vercel oidc-policies create --scope flagsmith \
  --name github-actions-frontend-deploy \
  --issuer https://token.actions.githubusercontent.com \
  --claim aud=https://github.com/Flagsmith \
  --claim repository=Flagsmith/flagsmith \
  --claim ref=refs/heads/main \
  --command deploy \
  --project flagsmith-frontend-production,flagsmith-frontend-demo,flagsmith-frontend-demo2

vercel oidc-policies is hidden and undocumented, and needs CLI 68.x. The three VERCEL_TOKEN secrets can be deleted once this lands.

How did you test this code?

The deploy workflow only runs on push to main, so not from this PR.

Ran the action's exchange step verbatim against the live API: a bad subject token surfaces Vercel's reason as an error annotation and exits 1, and a well-formed response captures and masks the token. The client ID matches VERCEL_CLI_CLIENT_ID in Vercel's source, and a made-up one returns App not found.

Unverified until it runs on main: the exchange against a real OIDC token, and that [email protected] stays within the policy's deploy scope. Reverting restores the previous behaviour.

🤖 Generated with Claude Code

The deploy step authenticated with VERCEL_TOKEN, a personal access token
that acts as the user who minted it. Enforcing 2FA on the Vercel team
made every call made with a token whose owner had not enrolled fail with
"You must set up Two-Factor Authentication before accessing this team",
taking out the production and demo deploys while demo2 — holding a
different user's token — carried on.

Exchange the job's GitHub OIDC token for a short-lived Vercel access
token instead, so no deploy depends on an individual's account state.
The Vercel CLI built-in app is cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp; the
team's OIDC policies pin the issuer, audience, repository, project and
allowed command.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@matthewelwell
matthewelwell requested a review from a team as a code owner December 2, 2026 15:05
@matthewelwell
matthewelwell requested review from bakirFS and removed request for a team December 2, 2026 15:05
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
docs Ignored Ignored Preview Dec 2, 2026 3:31pm UTC
flagsmith-frontend-preview Ignored Ignored Preview Dec 2, 2026 3:31pm UTC
flagsmith-frontend-staging Ignored Ignored Preview Dec 2, 2026 3:31pm UTC

Request Review

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-9220 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-9220 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-9220 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith:pr-9220 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith-api:pr-9220 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith-private-cloud:pr-9220 Finished ✅ Results ✅

@github-actions github-actions Bot added the ci-cd Build, test and deployment related label Dec 2, 2026

@cubic-dev-ai cubic-dev-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.

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Vercel ship OIDC login actions for the Container Registry and Turborepo,
but none for CLI deploys, so the exchange has to be done inline. Doing it
in github-script rather than shell drops the hand-built OIDC request URL
and both jq parses, and reports a failed exchange with the status and
body instead of a bare curl exit code.

v9 runs on Node 24, so this job stops emitting the Node 20 deprecation
warning as well.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added ci-cd Build, test and deployment related and removed ci-cd Build, test and deployment related labels Dec 2, 2026
@matthewelwell
matthewelwell marked this pull request as draft December 2, 2026 15:11

@cubic-dev-ai cubic-dev-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.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Turn on auto-fix | Re-trigger cubic

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-16 — run #24067 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  6 passed

Details

stats  6 tests across 6 suites
duration  1 minute, 7 seconds
commit  68c4613
info  🔄 Run: #24067 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #24067 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  59.5 seconds
commit  68c4613
info  🔄 Run: #24067 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #24067 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  33.8 seconds
commit  68c4613
info  🔄 Run: #24067 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #24067 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  35.5 seconds
commit  68c4613
info  🔄 Run: #24067 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #24066 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  45.5 seconds
commit  46d1ce6
info  🔄 Run: #24066 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #24066 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  8 passed

Details

stats  8 tests across 5 suites
duration  9.4 seconds
commit  46d1ce6
info  🔄 Run: #24066 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #24066 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  26 passed

Details

stats  26 tests across 15 suites
duration  42.5 seconds
commit  46d1ce6
info  🔄 Run: #24066 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #24066 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  35.9 seconds
commit  46d1ce6
info  🔄 Run: #24066 (attempt 1)

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Visual Regression

31 screenshots compared. See report for details.
View full report

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.96%. Comparing base (290a7b5) to head (77270e6).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9220      +/-   ##
==========================================
+ Coverage   98.10%   98.96%   +0.85%     
==========================================
  Files        1724     1724              
  Lines       73823    73879      +56     
==========================================
+ Hits        72425    73113     +688     
+ Misses       1398      766     -632     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The exchange was inline in the deploy job, first as shell and then as an
embedded script, leaving the workflow carrying auth plumbing either way.
Put it in .github/actions/vercel-login alongside codeartifact-login,
which solves the same problem for CodeArtifact, so the deploy job reads
as one step and the plumbing is swapped out in one line once Vercel ship
a login action for CLI deploys.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added ci-cd Build, test and deployment related and removed ci-cd Build, test and deployment related labels Dec 2, 2026
npm ci runs dependency install scripts, so a step-level VERCEL_TOKEN put
the deploy credential in reach of any package's postinstall and of the
bundle itself. Split the build from the deploy so only `vercel --prod`
sees it, and mint it after the build so a failed bundle does not exchange
a token at all.

Reported by cubic.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added ci-cd Build, test and deployment related and removed ci-cd Build, test and deployment related labels Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd Build, test and deployment related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant