Skip to content

[Pages] Add PowerShell deployment cleanup script example#32273

Open
MattieTK wants to merge 4 commits into
productionfrom
docs/pages-powershell-deployment-cleanup
Open

[Pages] Add PowerShell deployment cleanup script example#32273
MattieTK wants to merge 4 commits into
productionfrom
docs/pages-powershell-deployment-cleanup

Conversation

@MattieTK

Copy link
Copy Markdown
Member

Summary

Adds a Windows PowerShell version of the Pages deployment cleanup script alongside the existing macOS/Linux shell version (now in tabs), and improves both scripts to detect the production deployment by environment rather than by ID matching, run deletions in parallel, and print explicit guidance to create a production deployment first if none exists.

Continues the work from #31756 (opened by @AlexMnrs), moved here since I don't have push access to that branch's fork. Closes #31753.

Documentation checklist

AlexMnrs and others added 4 commits July 23, 2026 12:19
Replace both the macOS/Linux and Windows PowerShell examples with versions
that take the project name as an argument, detect the production deployment
via its Environment field, and delete preview deployments in parallel.
When no production deployment exists, the cleanup scripts now explain that one
is required and point to deploying to the production branch (with an example
wrangler command) instead of failing with a bare abort message.
@github-actions

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/pages/ @cloudflare/workers-docs, @GregBrimble, @WalshyDev, @aninibread, @irvinebroque, @cloudflare/product-owners, @MattieTK

@MattieTK
MattieTK marked this pull request as ready for review July 23, 2026 16:34
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review

⚠️ 2 warnings, 💡 1 suggestion found in commit 465f04d.

👉 Fix in your agent 👈
Fix the following review findings in PR #32273 (https://github.com/cloudflare/cloudflare-docs/pull/32273).

Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
  or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.

The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.

---

## Code Review

### Warnings (2)

#### CR-516ee9ab1f3f · PowerShell version mismatch
- **File:** `src/content/docs/pages/platform/known-issues.mdx` line 178
- **Issue:** ForEach-Object -Parallel and -ThrottleLimit are PowerShell 7+ only, but the tab is labeled 'Windows PowerShell' (the legacy 5.1 runtime), so users on that runtime will get a parameter binding error and the script will not run.
- **Fix:** Rename the tab to 'PowerShell 7+' or rewrite the script to use Start-Job/RunspacePool so it works in Windows PowerShell 5.1.

#### CR-47ad1532eea0 · Deletion failures silently ignored
- **File:** `src/content/docs/pages/platform/known-issues.mdx` line 144
- **Issue:** The inner sh -c uses `... || echo 'FAILED: $1'`. Because echo succeeds, the inner shell exits 0, so xargs exits 0 and the script prints 'Done.' even if every deletion failed.
- **Fix:** Aggregate failed IDs and exit non-zero when any deletion fails, matching the PowerShell script's failure handling.

---

## Style Guide Review

### Suggestions (1)

#### SG-74bbeb747de4 · Remove LLM-filler phrase
- **File:** `src/content/docs/pages/platform/known-issues.mdx` line 198
- **Issue:** Line begins with "Note that" before stating a fact.
- **Fix:** State the fact directly: "These scripts will not delete the active production deployment if one exists."

Code Review

This code review is in beta and may not always be helpful — use your judgment.

Warnings (2)
File Issue
pages/platform/known-issues.mdx line 178 PowerShell version mismatch — ForEach-Object -Parallel and -ThrottleLimit are PowerShell 7+ only, but the tab is labeled 'Windows PowerShell' (the legacy 5.1 runtime), so users on that runtime will get a parameter binding error and the script will not run. Fix: Rename the tab to 'PowerShell 7+' or rewrite the script to use Start-Job/RunspacePool so it works in Windows PowerShell 5.1.
pages/platform/known-issues.mdx line 144 Deletion failures silently ignored — The inner sh -c uses ... || echo 'FAILED: $1'. Because echo succeeds, the inner shell exits 0, so xargs exits 0 and the script prints 'Done.' even if every deletion failed. Fix: Aggregate failed IDs and exit non-zero when any deletion fails, matching the PowerShell script's failure handling.

Conventions

No convention issues found.

Style Guide Review

Suggestions (1)
File Issue
pages/platform/known-issues.mdx line 198 Remove LLM-filler phrase — Line begins with "Note that" before stating a fact. Fix: State the fact directly: "These scripts will not delete the active production deployment if one exists."
Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.
/disable-auto-review Stops automatic reviews from triggering on future pushes to this PR. Codeowners can still run /review or /full-review manually.
/rebase Rebases the PR branch against production. On conflict, attempts to resolve automatically using AI. Stops with an explanation if confidence is not high enough.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Windows PowerShell alternative for "delete project with too many deployments" guide

6 participants