PR Checks
Configure pr-check mode behavior.
This guide adds two GitHub Actions workflows: one that runs on pull requests to detect breaking changes, and one that handles automated versioning when changes land on main.
Before setting up the GitHub Action, the following are required:
contractual.yaml at the repository root.contractual/ directory with at least one snapshotIf those steps are not complete, follow the Quickstart first and commit the resulting files.
Create .github/workflows/contractual-pr.yml:
name: Contractual PR Check
on: pull_request: paths:
permissions: contents: write pull-requests: write
jobs: contractual-check: name: Check contracts runs-on: ubuntu-latest steps:
name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.head_ref }}
name: Run Contractual uses: contractual-dev/action@v1 with: mode: pr-check github-token: ${{ secrets.GITHUB_TOKEN }}
Create .github/workflows/contractual-release.yml:
name: Contractual Release
on: push: branches: [main] paths:
permissions: contents: write pull-requests: write
jobs: contractual-release: name: Version contracts runs-on: ubuntu-latest steps:
name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0
name: Run Contractual uses: contractual-dev/action@v1 with: mode: release github-token: ${{ secrets.GITHUB_TOKEN }}
git add .github/workflows/contractual-pr.ymlgit add .github/workflows/contractual-release.ymlgit commit -m "chore: add contractual workflows"git pushCreate a branch, edit a spec file, and open a pull request:
git checkout -b feat/update-order-schema# edit a spec file...git add schemas/order.schema.jsongit commit -m "feat: change amount field type"git push -u origin feat/update-order-schemaThe Contractual PR Check workflow will:
contractual lint to validate schemascontractual breaking to compare against the snapshotWhen the PR merges, the changeset lands on main and triggers the release workflow. It:
Merge that PR to complete the release. The action then:
orders-api@2.0.0)See Release Automation for configuration options.
| Permission | Level | Purpose |
|---|---|---|
contents | write | Commit changesets and version bumps |
pull-requests | write | Post PR comments and create Version PR |
PR Checks
Configure pr-check mode behavior.
Release Automation
Configure release mode and Version PRs.