Skip to main content

Changelog on Every PR

Prerequisites:

  • GitHub Actions Enabled
  • Optic initialized for your API project and checked in on the default branch of your repository for this to start working.

Once that's set up, use the following template to define a workflow in your repository's .github/workflows folder:

.github/workflows/optic-changelog.yml
name: Optic Changelog
on: [pull_request,workflow_dispatch]
jobs:  changelog:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v2      - uses: opticdev/optic-changelog@main        with:          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}          OPTIC_API_KEY: ${{secrets.OPTIC_API_KEY}}

Note, you may wish to modify the conditions on which the workflow will run, or modify it to meet your project's needs. If so, please review the GitHub workflow syntax

You'll need to add two environment variables, GITHUB_TOKEN which is automatically provided as a secret, and OPTIC_API_KEY. We highly recommend you add this API key as a secret in your repository and access it with the secrets variable as shown in the example. Otherwise, you risk leaking your key in your build environment.

There are two other optional environment variables you can configure:

  • SUBSCRIBERS - a comma-separated value of GitHub usernames to include in the PR comment, which will notify the users of an API change. Do not include the @ with the GitHub usernames.
  • OPTIC_SPEC_PATH - if your spec is not in the default place, you can pass in the correct path using this environment variable. ie .optic/api/specification.json

Once set up, this action will run and add a comment into your pull request, show a summary of what changed, and link to a full view of your APIs documentation and change.

Try it#

  • Make an API Change with Optic, either add an endpoint or change an existing one
  • Open a Pull Request