GitHub Action
Apollo Schema Check Action
A GitHub Action to run a schema check using the Apollo CLI and Apollo Studio (formerly Graph Manager) and post the results as a comment on a Pull Request
Create a file in your repo named .github/workflows/schema_check.yml
with the following contents:
name: Schema Check
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
check_schema:
name: check schema
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- name: Customer API check
uses: iansu/apollo-schema-check-action@v1
with:
title: Customer API
graph: my-customer-api
variant: production
localSchemaFile: 'schema.graphql'
serviceName: my-service
validationPeriod: P2W
key: ${{ secrets.APOLLO_KEY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
When you create a new PR that includes schema changes the results of the schema check will be posted as a comment. Here's an example of what that looks like:
Note that you won't see a comment if your PR doesn't include any schema changes.
Almost all of the settings from the Apollo CLI schema:check
command are supported, with the following differences:
- The
json
andmarkdown
options have been removed because this action requires markdown to post a comment on your PR - The
header
option works slightly different, you pass it a comma separated list of headers. For example:Header1=Value,Header2=Value2
.
Some additional settings have also been added:
Name | Description | Default | Required |
---|---|---|---|
title | The name of the graph which will be shown in the comment | No | |
alwaysComment | Leave a comment on the PR even if there are no schema changes in the PR | false | No |
failOnError | Fail the check if breaking changes or composition errors are found | true | No |
This Action offers some features that the Apollo GitHub App doesn't. If you don't need these features then you should consider using it instead. The main differences are:
- You don't have to install an app in your org or repo to use this Action
- This Action posts a comment with the results directly on your PR
- This Action supports multiple graphs
Made with 🥃 by Ian Sutherland (@iansu). This project is released under the MIT license.