Skip to content

fix: stop invalid preview workflow validation - #147

Merged
kentcdodds merged 2 commits into
mainfrom
cursor/fix-preview-main-trigger-215f
Apr 10, 2026
Merged

kentcdodds merged 2 commits into
mainfrom
cursor/fix-preview-main-trigger-215f

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Apr 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • remove the unsupported environments workflow permission from preview.yml
  • gate GitHub environment deletion behind an optional PREVIEW_ENVIRONMENT_GITHUB_TOKEN
  • move secret-based branching through job-level env so the workflow remains schema-valid

Testing

  • parse .github/workflows/preview.yml as YAML locally
  • lint .github/workflows/preview.yml with actionlint
  • push the branch and verify GitHub no longer creates a zero-second failed push run for preview.yml
  • open a draft PR and confirm the preview/validate workflows parse successfully on pull_request
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Chores
    • Enhanced preview environment cleanup process with conditional execution based on token availability for safer and more reliable environment management.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@coderabbitai

coderabbitai Bot commented Apr 10, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d73e2658-93b2-48e0-8b92-3bc643dbd4a3

📥 Commits

Reviewing files that changed from the base of the PR and between 1aed561 and 39c0569.

📒 Files selected for processing (1)
  • .github/workflows/preview.yml

📝 Walkthrough

Walkthrough

The workflow removes workflow-level environment permissions and adds token-based conditional logic to the cleanup job. The GitHub preview environment deletion now checks for token presence before attempting deletion, with the actions/github-script action using the token from environment variables instead of default permissions.

Changes

Cohort / File(s) Summary
GitHub Actions Workflow Configuration
.github/workflows/preview.yml
Removed workflow-level permissions.environments: write. Added PREVIEW_ENVIRONMENT_GITHUB_TOKEN environment variable to cleanup job from secrets. Inserted conditional step to skip environment deletion when token is unset, and modified deletion step to run only when token is non-empty. Updated actions/github-script to use explicit token from environment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A token now guards the cleanup gate,
Where environments meet their fate,
No permissions broad and wide,
Just conditions to decide—
The preview dance, more secure and light! 🌙

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/fix-preview-main-trigger-215f

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
kentcdodds marked this pull request as ready for review April 10, 2026 18:29
@kentcdodds
kentcdodds merged commit 33472e4 into main Apr 10, 2026
14 of 16 checks passed
@kentcdodds
kentcdodds deleted the cursor/fix-preview-main-trigger-215f branch April 10, 2026 18:29
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.

2 participants