Quick answer: Add Redocly CLI to the pipeline you already run. Lint the spec on every pull request with --format=github-actions so failures land on the changed lines and block the merge, then bundle and push only after the change reaches main. The same binary runs on your laptop, in CI, and in Docker, so a rule that passes locally is the rule CI applies.
Why lint belongs in CI, not just on your laptop
A spec that only gets checked when someone remembers to run the command drifts: one author adds an operation without a 4XX response, another reuses a schema name with a different shape, and neither sees it because the check lives on one machine. Running the CLI in CI makes the ruleset a shared gate. The build exits non-zero on a violation, and a red check keeps the pull request open until the spec is fixed.
The CLI behaves the same everywhere, which removes the "works on my machine" gap. Keep a redocly.yaml in the repo and every run picks up the same extends and custom rules. Without a config file, lint falls back to the recommended ruleset; a config file with no rules produces an error rather than silently using defaults. For where this fits against the rest of the vendor workflow, see the comparison hub.
A minimal GitHub Actions job
The shortest useful job is checkout plus one lint step. Using npx needs no global install, and pinning the version keeps the ruleset from changing underneath you on a new release.
name: API checks on: [pull_request] jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - run: npx @redocly/cli@1.34.0 lint openapi/openapi.yaml --format=github-actions The github-actions format emits workflow commands that GitHub turns into inline annotations on the diff, so the author sees the offending line instead of a log to scroll. If the repo already has a package.json, adding the CLI as a dev dependency and running it through npm ci is faster than a fresh npx download each run.
Which step runs where
Keeping read-only checks on pull requests and write steps on main limits where the API key is needed and where a bad change can reach a hosted project.
| Step | Pull request | Main branch | Why it sits there |
|---|---|---|---|
| Lint source spec | Yes | Yes | Fast feedback, blocks bad merges |
| Bundle to one file | No | Yes | Builds the artifact for accepted changes |
| Lint the bundle | No | Yes | Catches references broken by the build |
| Push to platform | No | Yes | Needs the key, not for fork pull requests |
| Deployment status | No | Yes | Confirms the hosted build finished cleanly |
Lint, then bundle, then lint again
Bundle is not a free pass. It merges the multi-file spec into one document and applies decorators, and a trim step such as remove-x-internal can leave a $ref pointing at a component that no longer exists. Lint the source, run the bundle with --output into a dist folder, then lint the bundled file before pushing it. That second lint catches a dangling reference or circular structure in the exact artifact a consumer will open, instead of surfacing it in a preview build.
Pushing without leaking the key
Pushing to a Redocly platform project needs an organization API key read from the REDOCLY_AUTHORIZATION environment variable. Store it as a repository secret and scope the push job to main-branch pushes, not pull requests, because fork pull requests should never touch that value. The push takes the organization and project identifiers, a mount path, branch, author, and message, and returns a push identifier.
Use that identifier with push-status to wait for the deployment and read the scorecard and link-checker results, or let the push command wait on the deployment itself. Do not append || true to a failing step; swallowing the exit code turns a gate into decoration. A dedicated push action is available and writes commit statuses, needing read access to contents and write access to statuses.
Frequently asked questions
Does this work on GitLab or other CI systems? The commands are identical; only the annotation format changes. Rely on the non-zero exit code to fail the job if your platform has no native annotations.
Should I pin the version or use latest? Pin it. A new release can tighten a rule, and tracking latest means a green pipeline can turn red overnight from a change you did not review.
Where does the API key go? In the CI secret store as REDOCLY_AUTHORIZATION, exposed only to the main-branch push job, never in a committed file or the pull-request lane.
The bottom line
CI integration is mostly about placement: read-only lint on every pull request, build and push on main, and a second lint on the bundled artifact. Lint confirms the spec is structurally sound, but a valid description does not prove the running API behaves; that takes request-level scenario tests against the live service, which is the part Powerduck focuses on alongside code review.