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 productionGotchas
- 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
How to Gate a Deploy With can-i-deployRun pact-broker can-i-deploy in CI before shipping so the broker confirms the version you are about to deploy…
How to Model Environments in the Pact BrokerCreate named environments in the Pact Broker such as test, staging, and production so record-deployment and c…