Previews and automatic cleanup
Enable pull request previews
Section titled “Enable pull request previews”- Open the Amplify app → Hosting → Previews
- Select branch
staging→ Edit settings - Turn Pull request previews Enabled → Confirm
- Leave
mainpreviews Disabled for this lab
After save, Hosting → Previews should show staging Enabled and main Disabled:
You will prove a preview URL on the next page:
https://pr-<number>.<app-id>.amplifyapp.comAutomatic cleanup
Section titled “Automatic cleanup”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”- Open the sample repo on GitHub → Settings → General
- Under Pull Requests, enable Automatically delete head branches
Amplify — remove preview hosts when the Git branch is gone
Section titled “Amplify — remove preview hosts when the Git branch is gone”- Open the Amplify app → Hosting / App settings → Repository settings (or Branch settings) → Edit
- Enable Branch auto-disconnection — “Automatically disconnect branches in Amplify when deleting a branch in your source repository”
- Leave Branch autodetection off for this lab (you already connected
mainandstagingmanually) - Keep Production branch as
main - Save
Without auto-disconnection, delete the preview branch in the Console yourself after the Git branch is gone.
Next: Prove the flow.