Skip to content

ci: track each Netlify preview and delete it when the PR closes - #52

Draft
carlosvin wants to merge 1 commit into
mainfrom
cursor/netlify-preview-lifecycle-ea66
Draft

carlosvin wants to merge 1 commit into
mainfrom
cursor/netlify-preview-lifecycle-ea66

Conversation

@carlosvin

Copy link
Copy Markdown
Owner

Summary

Pull requests already get a Netlify deploy preview for each shell, but GitHub only kept one deploy/netlify status, and those previews stayed online after merge. This adds a workflow that records a separate status per site and deletes the preview deploys when the pull request closes. Production still publishes from Netlify Git on push to main.

What changed

  • .github/workflows/netlify-previews.yml polls the Netlify API for the pull request head and posts netlify/side, netlify/prompt-first, and netlify/agentic.
  • On pull_request closed, the same workflow unlocks and deletes those deploy-preview deploys.
  • Setup scripts, README, and AGENTS.md describe the three checks, the cleanup, and the production path.

Required before this works

  1. Add a Netlify personal access token as the Actions secret NETLIFY_AUTH_TOKEN. Without it, the new jobs fail and previews are not deleted.
  2. On each Netlify site: production branch main, Deploy Previews on, branch deploys off.
  3. Netlify team: Notifications → Commit status webhooks → Multiple webhooks per repo, so Netlify’s own checks do not overwrite each other.
  4. Release Please is unchanged and still does not deploy. The failed run needs Settings → Actions → General → Workflow permissions → Allow GitHub Actions to create and approve pull requests, or a RELEASE_PLEASE_TOKEN secret.

Do not add the three netlify/* contexts to the required ruleset until the secret is set and a pull request shows them green.

Test

pnpm exec vitest run scripts/netlify/previewDeploys.test.ts — 4 passed. The test covers preview selection, commit matching, success status posting, and unlock-then-delete. It does not call Netlify or GitHub.

Open in Web Open in Cursor 

Post a distinct GitHub status for the side, prompt-first, and agentic
deploy previews, then delete those deploys after the pull request closes.
Production still publishes through Netlify Git on push to main.

Co-authored-by: carlosvin <carlosvin@gmail.com>
@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fullstack-promptable-app-example ready!

Name Link
🔨 Latest commit dddc4b5
🔍 Latest deploy log https://app.netlify.com/projects/fullstack-promptable-app-example/deploys/6ac75c76b3b5b20008f324a4
😎 Deploy Preview https://deploy-preview-52--fullstack-promptable-app-example.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fullstack-promptable-prompt-first ready!

Name Link
🔨 Latest commit dddc4b5
🔍 Latest deploy log https://app.netlify.com/projects/fullstack-promptable-prompt-first/deploys/6ac75c76d351d20008501938
😎 Deploy Preview https://deploy-preview-52--fullstack-promptable-prompt-first.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fullstack-promptable-agentic ready!

Name Link
🔨 Latest commit dddc4b5
🔍 Latest deploy log https://app.netlify.com/projects/fullstack-promptable-agentic/deploys/6ac75c778404fb00089fa52d
😎 Deploy Preview https://deploy-preview-52--fullstack-promptable-agentic.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants