DEVOPS

Tear Down Preview Deploys When a PR Merges or Closes

Listens for GitHub pull request merged or closed events and immediately deletes the associated Vercel preview deployments, posting a teardown confirmation to the PR.

CategoryDevOps
Enginesim
Difficultybeginner
Triggerwebhook
Steps6
Setup~5 min

How it runs

The automated pipeline, trigger to output.

  • TriggerGitHub PR closed/merged webhookGitHubGitHub
  • LogicConfirm close + extract head branch
  • ActionFind Vercel previews for that branchVercelVercel
  • LogicBranch: any matching previews?
  • ActionDelete matching preview deploymentsVercelVercel
  • OutputComment teardown summary on the PRGitHubGitHub

What it does

Reaps a pull request's preview environments the moment the PR is merged or closed, instead of waiting for a TTL to lapse. The PR thread gets a comment confirming which previews were removed.

When to use it

When previews are tied one-to-one with PRs and there is no reason to keep them once the PR is done. This is the tightest, cleanest policy: zero stale previews because they never outlive their PR.

How it works

  1. 1A GitHub webhook fires on pull_request `closed` (covers both merge and plain close).
  2. 2A filter confirms the action is a real close and extracts the branch name.
  3. 3Query the Vercel API for all preview deployments whose Git branch matches the PR head.
  4. 4A branch checks whether any matching previews exist; if none, the run ends quietly.
  5. 5Delete each matching preview deployment through the Vercel API.
  6. 6Post a comment back on the GitHub PR listing the torn-down preview URLs and confirming cleanup is complete.

Set it up

What you configure once, before turning it on.

  1. 1
    Connect GitHubRepos, issues, pull requests, actions.
  2. 2
    Connect VercelDeploys, runtime logs, analytics.
  3. 3
    Set each agent's modelWe leave models unset so you pick the tier — fast + cheap, or top-quality.
  4. 4
    Tune it to your dataEdit the prompts, filters, and field mappings so it matches how your team works.
  5. 5
    Test, then turn it onRun once against a sample, confirm the output, then enable the trigger.

Run this workflow in your colony.

14-day trial. No DevOps. No Sales call. Provisioned in under a minute.