Skip to content

[Pages] Add PowerShell deployment cleanup script example#32273

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

[Pages] Add PowerShell deployment cleanup script example#32273
MattieTK wants to merge 5 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

@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

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@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 suggestions found in commit 6fcac6f.

👉 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

### Suggestions (2)

#### CR-027d60504947 · Unquoted native-command arguments
- **File:** `src/content/docs/pages/platform/known-issues.mdx` line 186
- **Issue:** The PowerShell script invokes `npx ... wrangler pages deployment delete $id ... --project-name $using:ProjectName` without quoting `$id` or `$using:ProjectName`, so any value containing spaces would be split into multiple arguments.
- **Fix:** Quote the command arguments: `npx --no-install wrangler pages deployment delete "$id" --project-name "$using:ProjectName" --force *> $null`.

#### CR-4a42ccd3e14a · Redundant environment-variable assignment
- **File:** `src/content/docs/pages/platform/known-issues.mdx` line 165
- **Issue:** `$env:CLOUDFLARE_ACCOUNT_ID = $env:CLOUDFLARE_ACCOUNT_ID` reassigns the variable to its current value (or null to null) and does not actually ensure inheritance into parallel runspaces.
- **Fix:** Remove the line and its comment, or replace it with a clearer note that environment variables are already inherited by `ForEach-Object -Parallel` runspaces.

Code Review

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

Suggestions (2)
File Issue
pages/platform/known-issues.mdx line 186 Unquoted native-command arguments — The PowerShell script invokes npx ... wrangler pages deployment delete $id ... --project-name $using:ProjectName without quoting $id or $using:ProjectName, so any value containing spaces would be split into multiple arguments. Fix: Quote the command arguments: npx --no-install wrangler pages deployment delete "$id" --project-name "$using:ProjectName" --force \*> $null.
pages/platform/known-issues.mdx line 165 Redundant environment-variable assignment$env:CLOUDFLARE_ACCOUNT_ID = $env:CLOUDFLARE_ACCOUNT_ID reassigns the variable to its current value (or null to null) and does not actually ensure inheritance into parallel runspaces. Fix: Remove the line and its comment, or replace it with a clearer note that environment variables are already inherited by ForEach-Object -Parallel runspaces.

Conventions

No convention issues found.

Style Guide Review

No style-guide issues found.

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.

@MattieTK

Copy link
Copy Markdown
Member Author

/rebase

AlexMnrs and others added 5 commits July 24, 2026 13:37
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.
- Aggregate failed deletions in the bash script and exit non-zero instead
  of always printing "Done." (the previous `|| echo` swallowed the child
  exit code, so xargs and the script always reported success).
- Label the PowerShell tab "PowerShell 7+" since ForEach-Object -Parallel
  and -ThrottleLimit are not available in Windows PowerShell 5.1.
- Drop the "Note that" filler phrase.
@cloudflare-docs-bot
cloudflare-docs-bot Bot force-pushed the docs/pages-powershell-deployment-cleanup branch from 05006c4 to 6fcac6f Compare July 24, 2026 13:37
@MattieTK
MattieTK enabled auto-merge (squash) July 24, 2026 16:55
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