How to Run Accessibility Tests in GitHub Actions
Accessibility regressions are invisible until a user hits them; axe-core surfaces a large class of them automatically in CI.
Serve the app, then run @axe-core/cli (or axe via Playwright) against the URLs you care about so violations exit non-zero.
Steps
- Build and serve the site (or start the dev server).
- Run
@axe-core/cliagainst the target URLs. - Fail the job on any reported violation.
- Optionally scope rules to a WCAG level with tags.
Workflow
.github/workflows/a11y.yml
name: A11y
on: [pull_request]
jobs:
axe:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci && npm run build
- run: npx serve -l 8080 dist &
- run: npx wait-on http://localhost:8080
- run: npx @axe-core/cli http://localhost:8080 --exitNotes
- The
--exitflag makes axe return non-zero when violations are found. - Automated checks catch only part of WCAG; pair them with manual review.
Related guides
How to Run Lighthouse CI with Performance Budgets in GitHub ActionsRun Lighthouse CI against a built site in GitHub Actions and fail the build when performance, accessibility,…
How to Publish Storybook to Chromatic in GitHub ActionsBuild and publish Storybook to Chromatic from GitHub Actions for visual regression review on every pull reque…