Using Bowtie in GitHub Actions

Bowtie can be used from within GitHub Actions by using it in a GitHub workflow step. For example:

name: Run Bowtie
on: [push]

    runs-on: ubuntu-latest

      - name: Install Bowtie
        uses: bowtie-json-schema/bowtie@2024.6.18

See also

Workflow Syntax for GitHub Actions

for full details on writing GitHub Actions workflows

Once you have installed it, the Bowtie CLI will be available in successive run steps. Most commonly, you can use it to validate an instance (some data) using a specific JSON Schema implementation by adding:

- name: Validate Schema
  run: bowtie validate -i lua-jsonschema schema.json instance.json

replacing lua-jsonschema and the filenames with your implementation and schema of choice. For full details on the commands available, see the CLI documentation.

A fully working example of the above code can also be found here.

Including Bowtie Output in a Workflow Summary

Some of Bowtie’s commands, notably bowtie summary, support outputting in markdown format using the --format markdown option. This can be useful for including their output in GitHub Actions’ workflow summaries, e.g. to show validation results within the GitHub UI.

For example:

- name: Validate 37 is an Integer
  run: |
    bowtie validate -i python-jsonschema <(printf '{"type": "integer"}') <(printf '37') | bowtie summary --format markdown >> $GITHUB_STEP_SUMMARY
- name: Smoke Test a Bowtie Implementation
run: bowtie smoke -i go-jsonschema --format markdown >> $GITHUB_STEP_SUMMARY

See also

Displaying a Workflow Job’s Summary

for further details on GITHUB_STEP_SUMMARY