How to trigger pipeline runs only after PR merge (not on PR open/update)

Last updated: December 19, 2025

If you want your Spacelift pipeline to run only when a pull request is merged to your main branch, and not when PRs are opened or updated, you can achieve this using a Push policy.

Solution

Follow these steps to configure your stack to only trigger runs on PR merge:

  1. Keep your stack's tracked branch set to main

  2. In your Git provider (e.g., Bitbucket), keep Push events enabled in the webhook configuration

  3. Create a Push policy with the following code:

package spacelift

# Track ONLY pushes to the stack's tracked branch (e.g., main)

track {
  input.push.branch == input.stack.branch
}

propose { false }

ignore { not track }

How it works

This Push policy works by:

  • Tracking only the main branch: The track rule ensures that only pushes to your stack's tracked branch (typically main) are processed

  • Disabling proposed runs: The propose { false } rule prevents any proposed runs from being created

  • Ignoring other branches: The ignore { not track } rule ignores all pushes that don't match the tracking criteria

When a PR is merged, it creates a push to the main branch, which will trigger the pipeline run. However, when PRs are opened or updated on feature branches, they will be ignored by this policy.

Note: Make sure to create this as a Push policy, not a Trigger policy. Trigger policies work differently and won't achieve the desired behavior for this use case.