-
Notifications
You must be signed in to change notification settings - Fork 403
add script for deleting old deployments in Vercel #2300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Scripts | ||
|
|
||
| ## Bulk delete old Vercel deployments | ||
|
|
||
| `list-old-deployments.py` fetches all deployments for a given app via the Vercel API and writes UIDs of non-current-production deployments to `old-deployment-uids.txt`. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Vercel CLI installed and authenticated (`vercel login`) | ||
| - Access to the `saleorcommerce` scope | ||
|
|
||
| ### Usage | ||
|
|
||
| 1. Edit `APP_NAME` in the script to the target app. | ||
|
|
||
| 2. Run the script to generate the list: | ||
|
|
||
| ```bash | ||
| python3 scripts/list-old-deployments.py | ||
| ``` | ||
|
|
||
| This prints a table of all old deployments and writes their UIDs to `old-deployment-uids.txt` (one per line). | ||
|
|
||
| 3. Review the file and remove any deployments you want to keep (e.g. staging aliases): | ||
|
|
||
| ```bash | ||
| vim old-deployment-uids.txt | ||
| ``` | ||
|
|
||
| 4. Delete all remaining deployments (Vercel will show the list and ask for confirmation): | ||
|
|
||
| ```bash | ||
| vercel remove $(cat old-deployment-uids.txt) --scope saleorcommerce | ||
|
Check warning on line 33 in scripts/README.md
|
||
| ``` | ||
|
Comment on lines
+30
to
+34
|
||
|
|
||
| If there are too many for a single command, delete in batches of 50: | ||
|
|
||
| ```bash | ||
| vercel remove $(head -50 old-deployment-uids.txt) --scope saleorcommerce | ||
|
Check warning on line 39 in scripts/README.md
|
||
| # After confirming, remove processed lines: | ||
| sed -i '' '1,50d' old-deployment-uids.txt | ||
| # To skip ahead (e.g. next 50 starting at line 51): | ||
| vercel remove $(sed -n '51,100p' old-deployment-uids.txt) --scope saleorcommerce | ||
| ``` | ||
|
|
||
| 5. Re-run the script to verify everything was cleaned up: | ||
|
|
||
| ```bash | ||
| python3 scripts/list-old-deployments.py | ||
| ``` | ||
|
|
||
| ### Notes | ||
|
|
||
| - Vercel performs safe deletion — it will skip the current production deployment automatically. | ||
| - Vercel warns about alias removals before confirming — review these warnings before accepting. | ||
| - The `-s` flag skips the confirmation prompt (`vercel remove ... -s`). Use `-y` to auto-confirm. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,123 @@ | ||||||
| #!/usr/bin/env python3 | ||||||
| """List all Vercel deployments for saleor-app-smtp that are older than the current production deployment.""" | ||||||
|
||||||
| """List all Vercel deployments for saleor-app-smtp that are older than the current production deployment.""" | |
| """List Vercel deployments for the app defined in APP_NAME (default: saleor-app-products-feed), showing the current production deployment and all other non-current-production deployments.""" |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old_deps is described/printed as "Old deployments" but the filter currently removes only the current promoted production deployment. This will also include preview (and even newer-than-production) deployments, which makes it easy to accidentally delete recent previews someone may still be using. If the intent is truly "older than current production", filter by created < current_prod['created'] (and possibly also keep the newest preview per branch); otherwise rename the variable/output to reflect "non-current production" instead of "old".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script uses Python 3.10+ typing syntax (
list[dict],int | None). The README only sayspython3; please document the minimum required Python version (or switch totyping.List/Optionalif you want broader compatibility).