Workflows

CI / CD

A fresh, production-shaped database for every pull request. Isolated, real data, torn down after the run.

Per-PR branch

DATABASE_URL="$(anybranch create "pr-$PR_NUMBER" --from prod --print-url)"
[ -n "$DATABASE_URL" ] || exit 1
export DATABASE_URL
# run migrations and the test suite against $DATABASE_URL
anybranch rm "pr-$PR_NUMBER"

GitHub Actions

env:
  ANYBRANCH_SERVER: https://anybranch.internal
  ANYBRANCH_TOKEN: ${{ secrets.ANYBRANCH_TOKEN }}
steps:
  - run: |
      DATABASE_URL="$(anybranch create pr-${{ github.event.number }} --from prod --print-url)"
      export DATABASE_URL
      ./run-migrations && ./test
  - if: always()
    run: anybranch rm pr-${{ github.event.number }}

Use if: always() (or your CI’s equivalent) so the branch is deleted even when tests fail. Set ANYBRANCH_TOKEN as a secret; nothing else is needed.

Tip: because a branch is copy-on-write, a per-PR database of any size is instant and costs disk only for what the tests change. Delete it after the run to release that.