Skip to content

add script for deleting old deployments in Vercel#2300

Open
witoszekdev wants to merge 3 commits intomainfrom
add-vercel-script
Open

add script for deleting old deployments in Vercel#2300
witoszekdev wants to merge 3 commits intomainfrom
add-vercel-script

Conversation

@witoszekdev
Copy link
Copy Markdown
Contributor

With this script we can delete old deployments in Vercel, tested already for smtp and product-feed apps

@witoszekdev witoszekdev requested a review from a team as a code owner March 30, 2026 15:39
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
saleor-app-avatax Ready Ready Preview, Comment Mar 30, 2026 3:43pm
saleor-app-cms Ready Ready Preview, Comment Mar 30, 2026 3:43pm
saleor-app-payment-np-atobarai Ready Ready Preview, Comment Mar 30, 2026 3:43pm
saleor-app-payment-stripe Ready Ready Preview, Comment Mar 30, 2026 3:43pm
saleor-app-products-feed Ready Ready Preview, Comment Mar 30, 2026 3:43pm
saleor-app-search Ready Ready Preview, Comment Mar 30, 2026 3:43pm
saleor-app-segment Ready Ready Preview, Comment Mar 30, 2026 3:43pm
saleor-app-smtp Ready Ready Preview, Comment Mar 30, 2026 3:43pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
saleor-app-klaviyo Ignored Ignored Preview Mar 30, 2026 3:43pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 30, 2026

⚠️ No Changeset found

Latest commit: 7dfba83

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@witoszekdev witoszekdev added the skip changeset Attach this label to PRs which does not need changes description for the release notes. label Mar 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a small utility under scripts/ to help identify and bulk-delete Vercel deployments for a given app by generating a UID list, along with usage documentation for running the workflow from the CLI.

Changes:

  • Added list-old-deployments.py to fetch/paginate Vercel deployments, identify the current promoted production deployment, and output non-current deployment UIDs for deletion.
  • Added scripts/README.md documenting prerequisites and the batch deletion workflow using Vercel CLI.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
scripts/list-old-deployments.py Implements deployment listing/pagination and writes a UID file intended for bulk deletion.
scripts/README.md Documents how to run the script and delete deployments in batches.

Comment thread scripts/README.md
Comment on lines +7 to +20
### 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
```
Copy link

Copilot AI Mar 30, 2026

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 says python3; please document the minimum required Python version (or switch to typing.List/Optional if you want broader compatibility).

Copilot uses AI. Check for mistakes.
Comment thread scripts/README.md
Comment on lines +30 to +34
4. Delete all remaining deployments (Vercel will show the list and ask for confirmation):

```bash
vercel remove $(cat old-deployment-uids.txt) --scope saleorcommerce
```
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sed -i '' ... examples are BSD/macOS-specific; on GNU/Linux sed -i syntax differs. Please either mention the platform assumption or provide a Linux-compatible alternative command in the README so the instructions work for all contributors.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,123 @@
#!/usr/bin/env python3
"""List all Vercel deployments for saleor-app-smtp that are older than the current production deployment."""
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module docstring says this lists deployments for saleor-app-smtp and that they are "older than the current production deployment", but the script defaults APP_NAME to saleor-app-products-feed and the later filter includes all non-current-production deployments regardless of age. Please update the docstring to match the actual behavior (or adjust the filtering logic to match the docstring).

Suggested change
"""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 uses AI. Check for mistakes.
Comment on lines +80 to +90
# Filter: everything except current production, not already soft-deleted
old_deps = [
d
for d in all_deps
if d["uid"] != current_prod["uid"] and not d.get("softDeletedByRetention")
]

print(
f"\nOld deployments to delete: {len(old_deps)} (out of {len(all_deps)} total)\n",
file=sys.stderr,
)
Copy link

Copilot AI Mar 30, 2026

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".

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.24%. Comparing base (b4c3ab7) to head (7dfba83).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2300   +/-   ##
=======================================
  Coverage   37.24%   37.24%           
=======================================
  Files        1015     1015           
  Lines       65929    65929           
  Branches     3391     3391           
=======================================
  Hits        24557    24557           
  Misses      40997    40997           
  Partials      375      375           
Flag Coverage Δ
avatax 57.39% <ø> (ø)
cms 18.67% <ø> (ø)
domain 100.00% <ø> (ø)
dynamo-config-repository 79.29% <ø> (ø)
errors 91.66% <ø> (ø)
logger 28.81% <ø> (ø)
np-atobarai 72.69% <ø> (ø)
products-feed 5.91% <ø> (ø)
search 30.74% <ø> (ø)
segment 32.38% <ø> (ø)
shared 37.35% <ø> (ø)
smtp 34.91% <ø> (ø)
stripe 71.09% <ø> (ø)
webhook-utils 11.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lkostrowski
Copy link
Copy Markdown
Member

why not typescript?

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

Labels

skip changeset Attach this label to PRs which does not need changes description for the release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants