Skip to content

Fix Xata preview cleanup for Dependabot and fork PRs#43

Merged
exekias merged 1 commit into
mainfrom
fix-cleanup-preview-secrets
Jun 5, 2026
Merged

Fix Xata preview cleanup for Dependabot and fork PRs#43
exekias merged 1 commit into
mainfrom
fix-cleanup-preview-secrets

Conversation

@exekias

@exekias exekias commented Jun 5, 2026

Copy link
Copy Markdown
Member

Problem

The "Cleanup Preview Branch" workflow silently does nothing on Dependabot PRs (example run). Dependabot-triggered pull_request events run without access to repository Actions secrets, so XATA_API_KEY, XATA_ORG_ID, and XATA_MAIN_PROJECT_ID were all empty and the Xata CLI failed with Error: No token provided. The || true then masked the failure, so runs showed green while preview branches leaked. Fork PRs have the same gap.

Fix

  • Switch the trigger from pull_request to pull_request_target, which runs in the base-repo context and gets the real secrets. Safe here: the workflow never checks out or executes PR code, and the only PR-controlled input (head.ref) is sanitized with tr before use.
  • Fail loudly if XATA_API_KEY is empty instead of reporting a green no-op.

Note: the new trigger takes effect for PRs closed after this lands on main (pull_request_target reads the workflow from the base branch), which also means it immediately covers already-open Dependabot PRs once merged. Preview branches leaked by past runs (e.g. preview-dependabot-npm_and_yarn-pg-8-21-0) need manual cleanup in Xata.

🤖 Generated with Claude Code

Dependabot-triggered pull_request events run without access to
repository Actions secrets, so XATA_API_KEY & co. were empty and the
CLI failed with "No token provided" — silently swallowed by `|| true`,
leaking preview branches.

Switch to pull_request_target, which runs in the base-repo context with
real secrets. This is safe here: the workflow never checks out or runs
PR code, and the only PR-controlled input (head.ref) is sanitized
before use. Also fail loudly if the API key is missing instead of
reporting a green no-op.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
learn-postgres Ready Ready Preview Jun 5, 2026 8:40am

@exekias exekias merged commit 1acc49d into main Jun 5, 2026
3 checks passed
@exekias exekias deleted the fix-cleanup-preview-secrets branch June 5, 2026 08:41
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