Skip to content
Latchkey

How to Record Deployments and Releases in the Pact Broker

record-deployment marks a version as running in an environment; record-release marks it as available without pinning it to a running instance.

After a successful deploy, run pact-broker record-deployment with the pacticipant, version, and environment. Use record-release for artifacts published to a registry rather than deployed to a running environment.

Steps

  • Run record-deployment as the final step of a successful deploy job.
  • Use the same version sha you passed to can-i-deploy.
  • Prefer record-release for libraries and package artifacts.

Record step

.github/workflows/ci.yml
      - name: Record deployment
        if: success()
        env:
          PACT_BROKER_BASE_URL: ${{ vars.PACT_BROKER_BASE_URL }}
          PACT_BROKER_TOKEN: ${{ secrets.PACT_BROKER_TOKEN }}
        run: |
          npx pact-broker record-deployment \
            --pacticipant web \
            --version "${GITHUB_SHA}" \
            --environment production

Gotchas

  • record-deployment automatically marks the previously deployed version as no longer deployed in that environment.
  • If you skip recording, can-i-deploy compares against stale data and can pass or block incorrectly.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →