CAVEATS v2 is intended to help in migrating from tag to branches.
If ensure, use v1 if your pact publish -> verification still need to be performed using tags
This action uses pact-cli docker image to perform an opinionated "publish contract":
$ pact broker publish <PACT_OR_DIR> \
--consumer-app-version <GIT_COMMIT_SHA> \
--branch <GIT_BRANCH> \
--tag <GIT_BRANCH> \
--no-auto-detect-version-properties
Action inputs are (hopefully) kept in sync with relation option of publish
command from pact-cli
Required Directory with pact contract files.
See examples below for more info about how actually use in workflow.
Required The consumer application version.
Required Repository branch of the consumer version.
Setup environment variable used by pact-cli
.
Required The base URL of the Pact Broker
Required Pact Broker basic auth username
Required Pact Broker basic auth password
Being a Docker container action, the workspace directory path for action is
mounted inside docker container run by the action as /github/workspace
.
So, use /github/workspace
as base path in directory
input value and append the relative path to pact contract directory files.
steps:
# ...
# assume this will put pact files into $GITHUB_WORKSPACE/build/pacts
- name: consumer contract test
run: make test-contract-consumer
# GitHub Action provides different env var for branch name if on pull request
- name: Output git branch
id: git-branch
run: |
echo ::set-output name=head_ref::${GITHUB_HEAD_REF#refs/*/}
echo ::set-output name=ref::${GITHUB_REF#refs/*/}
- uses: casavo/pact-publish-contract-action@v1
env:
PACT_BROKER_BASE_URL: ${{ secrets.PACT_BROKER_BASE_URL }}
PACT_BROKER_PASSWORD: ${{ secrets.PACT_BROKER_PASSWORD }}
PACT_BROKER_USERNAME: ${{ secrets.PACT_BROKER_USERNAME }}
with:
directory: /github/workspace/build/pacts
consumer_app_version: ${{ github.sha }}
branch: ${{ steps.git-branch.outputs.head_ref || steps.git-branch.outputs.ref }}