Skip to content

Previews and automatic cleanup

  1. Open the Amplify app → Hosting → Previews
  2. Select branch staging → Edit settings
  3. Turn Pull request previews Enabled → Confirm
  4. Leave main previews Disabled for this lab
Amplify Manage preview settings for staging — Pull request previews Enabled

After save, Hosting → Previews should show staging Enabled and main Disabled:

Amplify Previews table — main Disabled, staging Enabled

You will prove a preview URL on the next page:

https://pr-<number>.<app-id>.amplifyapp.com

Two separate switches — GitHub deletes the Git head branch; Amplify disconnects the matching Amplify branch (preview hosts after feature merges; also staging if Git staging was deleted).

GitHub — delete head branches after merge

Section titled “GitHub — delete head branches after merge”
  1. Open the sample repo on GitHub → Settings → General
  2. Under Pull Requests, enable Automatically delete head branches
GitHub Settings — Automatically delete head branches enabled

Amplify — remove preview hosts when the Git branch is gone

Section titled “Amplify — remove preview hosts when the Git branch is gone”
  1. Open the Amplify app → Hosting / App settings → Repository settings (or Branch settings) → Edit
  2. Enable Branch auto-disconnection — “Automatically disconnect branches in Amplify when deleting a branch in your source repository”
  3. Leave Branch autodetection off for this lab (you already connected main and staging manually)
  4. Keep Production branch as main
  5. Save
Amplify Edit repository settings — branch auto-disconnection enabled, autodetection off, production branch main

Without auto-disconnection, delete the preview branch in the Console yourself after the Git branch is gone.

Next: Prove the flow.