Fix Xata preview cleanup for Dependabot and fork PRs#43
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The "Cleanup Preview Branch" workflow silently does nothing on Dependabot PRs (example run). Dependabot-triggered
pull_requestevents run without access to repository Actions secrets, soXATA_API_KEY,XATA_ORG_ID, andXATA_MAIN_PROJECT_IDwere all empty and the Xata CLI failed withError: No token provided. The|| truethen masked the failure, so runs showed green while preview branches leaked. Fork PRs have the same gap.Fix
pull_requesttopull_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 withtrbefore use.XATA_API_KEYis empty instead of reporting a green no-op.Note: the new trigger takes effect for PRs closed after this lands on
main(pull_request_targetreads 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