feat: support branch-scoped preview deployments + cleanup#16
feat: support branch-scoped preview deployments + cleanup#16lustsazeus-lab wants to merge 5 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a new reusable GitHub Actions workflow (deno-deploy-preview-cleanup.yml) to delete Deno Deploy preview projects on branch deletion. The cleanup workflow validates inputs, computes or accepts the preview project name (with branch/shared strategies, slugging, truncation and sha1 suffixing), can skip deletion for production branches, and issues a DELETE to the Deno API (treating 404 as success). The deployment workflow gains 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e18a3d0ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [ $max_branch_len -lt 6 ]; then | ||
| echo "::error::Cannot build branch preview name for base '${base}' within Deno project length limits" |
There was a problem hiding this comment.
Avoid hard-failing branch previews for longer project names
Because preview_strategy now defaults to branch, this check causes preview deployments to fail for any valid project whose base name is longer than 12 characters (for example notifications-ubq-fi, where max_branch_len becomes 5). Existing repos that do not explicitly opt back to shared will start failing on non-production branches, even though those previews previously deployed successfully.
Useful? React with 👍 / 👎.
…t names When a project's base name is too long (e.g. notifications-ubq-fi with base='notifications'), max_branch_len becomes <6, making branch-based preview naming impractical (0-char branch slug + hash = ugly leading hyphens like '-a1b2c-notifications-ubq-fi'). Instead of exiting with an error, fall back to shared preview naming silently so repos with long names don't break after upgrading without having to explicitly set strategy=shared. P1 feedback from chatgpt-codex-connector[bot] on PR ubiquity#16.
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ed9b06fe-0992-41fd-96de-0cea0c9b7c1c
📒 Files selected for processing (3)
.github/workflows/deno-deploy-preview-cleanup.yml.github/workflows/deno-deploy-reusable.ymlREADME.md
… naming - deno-deploy-reusable.yml: Add explicit 'strategy=shared' block to handle the case where strategy is explicitly set to 'shared' with mode=preview. Previously the preview variable was never set in this case, causing DNS-validation to fail on an empty string. Now shared strategy (whether explicit or auto-switched due to long branch names) is handled consistently. - deno-deploy-preview-cleanup.yml: Align empty-slug handling with deploy workflow. When slugify returns empty, fall back to 'preview' slug (like deploy does) instead of silently skipping. Also add auto-switch to shared strategy when max_branch_len < 6, consistent with deploy behavior. - README.md: Document the auto-fallback-to-shared behavior for repos with very long base names that cannot fit any branch preview prefix.
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 95a0b676-1b7a-4d93-8144-1871c9a53bfc
📒 Files selected for processing (3)
.github/workflows/deno-deploy-preview-cleanup.yml.github/workflows/deno-deploy-reusable.ymlREADME.md
✅ Files skipped from review due to trivial changes (2)
- README.md
- .github/workflows/deno-deploy-reusable.yml
… project deletion Address CodeRabbit feedback: - Validate preview_strategy is 'branch' or 'shared' in both deno-deploy-reusable.yml and deno-deploy-preview-cleanup.yml; fail fast on unknown values to prevent the wrong preview project from being deleted. - Add explicit guard in cleanup workflow: refuse to DELETE the production project if target resolves to the base project name (prevents catastrophic deletion). Fixes remaining issues from ubiquity#16 CodeRabbit review.
|
There is still a branch-collision case in the default In both the deploy and cleanup workflows, when the base project name leaves fewer than six chars for the branch prefix, the code switches suffix="-${base}-ubq-fi"
max_branch_len=$((26 - ${#suffix}))
if [ $max_branch_len -lt 6 ]; then
strategy="shared"
fiFor a repo like the comment's own example This seems to miss the core requirement from #7: "support any branch as the prefix instead of collapsing all of them into |
Summary
This PR implements branch-scoped preview deployments for the reusable Deno Deploy workflow, plus automatic cleanup support when branches are deleted.
Changes
preview_strategyinput todeno-deploy-reusable.ymlbranchsharedfeat/widget+pay-ubq-fi->feat-widget-pay-ubq-fi<branch>-<subdomain>.ubq.fi).github/workflows/deno-deploy-preview-cleanup.ymlpreview_strategyValidation
./.tools/actionlint/actionlint✅Fixes #7
/claim #7