8. Publish your consumer contract to PactFlow
Now that we have created our consumer contract, we need to share it to our provider. This is where PactFlow comes in to the picture. This step is referred to as "publishing" the consumer contract.
Publish the consumer build locally
As per step 4, we're going to need credentials to our PactFlow account here:
Go to PactFlow and copy your read/write API Token
Export these two environment variables into the terminal, being careful to replace the placeholders with your own values:
export PACT_BROKER_BASE_URL=https://YOUR_PACTFLOW_SUBDOMAIN.pactflow.io
export PACT_BROKER_TOKEN=YOUR_API_TOKENnpm run publish
Go to your PactFlow dashboard and check that a new contract has appeared
Your dashboard should look something like this:
Expected state by the end of this step
- There should be a contract published in your PactFlow account before moving on
Publish the consumer build in Github Actions
In Github:
- Open your forked
example-bi-directional-consumer-<tool>
project (https://github.com/<your-username>/example-bi-directional-consumer-<tool>
) - Click on the
Actions
tab. - Click the button with the text "I understand my workflows, go ahead and enable them"
- Under the
Workflows
menu on the left, selectBuild
. - You will see the text
This workflow has a workflow_dispatch event trigger
. To the right of that text is a button with the labelRun workflow
. Click the button. - Leave the branch as
master
and click the greenRun workflow
button.
❌ The build will fail with an authentication error when it tries to publish the pact - that's expected. We need to update the configuration to point it at your new PactFlow account.
Expected state by the end of this step
- The consumer build fails with authentication errors, don't worry, we will address this in the next step ❌