This guide builds a daily accessibility scan for a site that several teams work on, using pa11y in GitHub Actions. The scan sends issue counts to Datadog, alerts Slack when errors go up and writes an HTML report that groups issues by UI component, with an owner team for each component. The examples use pa11y 10.0.0, which bundles axe-core 4.13.0 and HTML_CodeSniffer 2.6.0, and Puppeteer 25.19.0 on Node.js 24. These are the current npm versions on 1 December 2026.
Automated tools check only part of WCAG, and the W3C says it plainly: tools cannot check all accessibility aspects, and human judgement is required. A daily scan finds regressions early, but it does not tell you that a site is accessible, so use it next to manual tests with a keyboard and a screen reader.
What you build
- A scheduled GitHub Actions job that scans a list of pages in headless Chromium, including pages behind a login.
- Two rule sets: HTML_CodeSniffer for WCAG 2.0 AA and axe-core for WCAG 2.1 AA rules.
- Datadog metrics for the issue count, the scan duration and the scan status, with tags for locale, page type, team and rule.
- A Datadog monitor that alerts Slack when the error count rises.
- An HTML report on GitHub Pages, grouped by component, with screenshots of failing elements.
Install pa11y and Puppeteer:
npm install pa11y puppeteer
pa11y 10 needs Node.js 22.13 or later and depends on Puppeteer 25. The script below passes its own browser to pa11y, and the pa11y README says that Puppeteer must then match the version range that pa11y uses. Node.js 24 runs .mts files directly by stripping the types, but pa11y ships no TypeScript types, so add declare module 'pa11y'; in a .d.ts file if you run tsc. All snippets below go in one file, scan.mts.
Choose the runners and the standard
pa11y runs HTML_CodeSniffer by default, so add axe-core as a second runner. With the standard WCAG2AA, the axe runner checks the rules tagged for WCAG 2.0 and 2.1 level A and AA, plus the rules with the axe tag best-practice.
import { mkdir, writeFile } from 'node:fs/promises';
import pa11y from 'pa11y';
import puppeteer, { type Browser, type Page } from 'puppeteer';
type Target = { url: string; locale: string; pageType: string; team: string; actions?: string[] };
type Issue = {
code: string;
type: string;
message: string;
context: string | null;
selector: string | null;
runner: string;
};
type ScanResult = {
target: Target;
ok: boolean;
durationMs: number;
issues: Issue[];
shots: Record<string, string>;
};
async function scan(browser: Browser, target: Target): Promise<ScanResult> {
const page = await browser.newPage();
const started = Date.now();
try {
const result = await pa11y(target.url, {
browser,
page,
runners: ['htmlcs', 'axe'],
standard: 'WCAG2AA',
includeWarnings: true,
includeNotices: true,
levelCapWhenNeedsReview: 'warning',
timeout: 60_000,
actions: target.actions ?? [],
});
const shots = await captureComponents(page, result.issues, target);
return { target, ok: true, durationMs: Date.now() - started, issues: result.issues, shots };
} catch {
return { target, ok: false, durationMs: Date.now() - started, issues: [], shots: {} };
} finally {
await page.close();
}
}
Some notes on the options:
includeWarningsandincludeNoticesarefalseby default. Turn them on to see items that need a human check, but alert only on errors.- The axe runner maps impact to type: critical and serious become errors, moderate becomes a warning and minor becomes a notice.
levelCapWhenNeedsReview: 'warning'keeps axe results that need review out of the error count. - Set
timeoutyourself, because a product page with many images can take a while and the scan should not fail on a slow page. - When you pass
browserandpage, pa11y does not close them. You cannot reuse a page for a second run, so the code opens a new page per target and closes it infinally. - A failed scan returns
ok: false, which the scan status metric reports, so a broken page does not look like a page without errors.
If a rule gives false positives on your site, add its code to the ignore option, where pa11y compares the codes in lowercase. Keep this list short and review it.
Scan pages behind a login
pa11y can run actions before the test, which is how the scan reaches account pages. The example below fits a two-step login: email first, then password.
const SITE = process.env.SITE ?? 'https://www.example.com';
const { SCAN_EMAIL, SCAN_PASSWORD } = process.env;
function behindLogin(locale: string, path: string): string[] {
return [
`set field #email to ${SCAN_EMAIL}`,
'click element #continue',
'wait for element #password to be visible',
`set field #password to ${SCAN_PASSWORD}`,
'click element button[type="submit"]',
`wait for path to not be /${locale}/login`,
`navigate to ${SITE}/${locale}${path}`,
];
}
Use a test account that holds no real customer data, and store the email and password as GitHub Actions secrets. Do not set the pa11y log level to debug in CI, because at that level pa11y logs every action, including the password.
Group issues by UI component
A list of issues per page is long and repetitive. A product card with an unlabelled button shows up on every page that has a product card, in every locale, so a page list shows that one bug many times. It also does not say who should fix it, because one page holds components from several teams.
Grouping by component fixes both problems. The product card becomes one entry, with one owner team and a list of the pages where it fails, and one fix in the component clears all of those issues. The team gets a short list it can plan instead of a long list it has to sort.
pa11y returns an HTML snippet of each failing element in context, and the code reads the component name from a CSS Modules class name in that snippet. The pattern matches names like ProductCard_root__x7Ab2, so adapt it to the naming scheme of your build.
const CSS_MODULE_CLASS = /\b([A-Z][A-Za-z0-9]+)_[A-Za-z0-9]+__[A-Za-z0-9_-]+/;
function componentOf(issue: Issue): string {
const html = issue.context ?? '';
const cssModule = html.match(CSS_MODULE_CLASS);
if (cssModule) return cssModule[1];
const tag = html.match(/^<([a-z][a-z0-9-]*)/i);
return tag ? `<${tag[1].toLowerCase()}>` : 'unattributed';
}
// Example team names. Keep this map next to your component code.
const OWNERS: Record<string, string> = {
productcard: 'discovery',
minicart: 'checkout',
footer: 'platform',
};
type Group = {
component: string;
team: string;
counts: Record<string, number>;
pages: Set<string>;
rules: Map<string, number>;
shots: Set<string>;
};
function groupByComponent(results: ScanResult[]): Group[] {
const groups = new Map<string, Group>();
for (const { target, issues, shots } of results) {
for (const issue of issues) {
const component = componentOf(issue);
let group = groups.get(component);
if (!group) {
group = {
component,
team: OWNERS[component.toLowerCase()] ?? 'unassigned',
counts: { error: 0, warning: 0, notice: 0 },
pages: new Set(),
rules: new Map(),
shots: new Set(),
};
groups.set(component, group);
}
group.counts[issue.type] += 1;
group.pages.add(`${target.locale} ${target.pageType}`);
group.rules.set(issue.code, (group.rules.get(issue.code) ?? 0) + 1);
if (shots[component]) group.shots.add(shots[component]);
}
}
return [...groups.values()].sort((a, b) => b.counts.error - a.counts.error);
}
When an element has no component class, the code falls back to the tag name, and issues without a snippet end up as unattributed. Watch the size of those two groups, because if they grow, your class names do not reach the failing elements.
Take screenshots of failing elements
After pa11y returns, the page is still open, so the code finds the first failing element per component, draws an outline around it and takes a screenshot. ElementHandle.screenshot fails on elements with zero width or height, so the code skips those.
async function captureComponents(page: Page, issues: Issue[], target: Target) {
const shots: Record<string, string> = {};
for (const issue of issues) {
const component = componentOf(issue);
if (issue.type !== 'error' || !issue.selector || shots[component]) continue;
const element = await page.$(issue.selector);
const box = await element?.boundingBox();
if (!element || !box || box.width === 0 || box.height === 0) continue;
await element.evaluate((node) => {
(node as HTMLElement).style.outline = '3px solid red';
(node as HTMLElement).style.outlineOffset = '-3px';
});
const file = `shots/${target.locale}-${target.pageType}-${component.replace(/\W/g, '')}.png`;
await element.screenshot({ path: `report/${file}` });
shots[component] = file;
}
return shots;
}
Write the HTML report
The report has one section per component: the owner team, the counts, the pages, the rules and the screenshots. Rule codes and component names can contain < and >, so escape them.
const escape = (text: string) =>
text.replace(/[&<>"]/g, (char) => `&#${char.charCodeAt(0)};`);
function renderReport(groups: Group[]): string {
const sections = groups.map((group) => {
const rules = [...group.rules]
.sort((a, b) => b[1] - a[1])
.map(([rule, count]) => `<li><code>${escape(rule)}</code>: ${count}</li>`)
.join('');
const images = [...group.shots]
.map((src) => `<img src="${src}" alt="Failing element in ${escape(group.component)}" width="320">`)
.join('');
return `<section>
<h2>${escape(group.component)} <small>owner: ${escape(group.team)}</small></h2>
<p>${group.counts.error} errors, ${group.counts.warning} warnings on ${group.pages.size} pages:
${escape([...group.pages].join(', '))}</p>
<ul>${rules}</ul>
${images}
</section>`;
});
return `<!doctype html><html lang="en"><meta charset="utf-8">
<title>Accessibility report</title>${sections.join('\n')}</html>`;
}
Send metrics to Datadog
Each scan sends three metrics through the Datadog metrics API: a11y.issues.count, a11y.scan.duration_ms and a11y.scan.success. They are gauges (type 3) with a timestamp in seconds.
const tagValue = (value: string) => value.toLowerCase().replace(/[^a-z0-9_.:/-]/g, '_');
function toSeries({ target, ok, durationMs, issues }: ScanResult, now: number) {
const base = [`locale:${target.locale}`, `page_type:${target.pageType}`, `team:${target.team}`];
const gauge = (metric: string, value: number, tags: string[] = []) => ({
metric,
type: 3, // gauge
points: [{ timestamp: now, value }],
tags: [...base, ...tags],
});
const counts = new Map<string, number>();
for (const issue of issues) {
const key = `${issue.type}|${tagValue(issue.code)}`;
counts.set(key, (counts.get(key) ?? 0) + 1);
}
const series = [
gauge('a11y.scan.duration_ms', durationMs),
gauge('a11y.scan.success', ok ? 1 : 0),
];
for (const [key, count] of counts) {
const [type, rule] = key.split('|');
series.push(gauge('a11y.issues.count', count, [`type:${type}`, `rule:${rule}`]));
}
if (ok && !issues.some((issue) => issue.type === 'error')) {
series.push(gauge('a11y.issues.count', 0, ['type:error', 'rule:none']));
}
return series;
}
async function sendSeries(series: object[]) {
const response = await fetch(`https://api.${process.env.DD_SITE}/api/v2/series`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'DD-API-KEY': process.env.DD_API_KEY ?? '',
},
body: JSON.stringify({ series }),
});
if (!response.ok) throw new Error(`Datadog answered ${response.status}`);
}
Three details matter here:
- Zero series. When a page has no errors, the code sends a
0, because without it the error count of a fixed page has no data instead of zero. - Tag values. Datadog lowercases tags and turns characters such as commas into underscores. HTML_CodeSniffer codes like
WCAG2AA.Principle1.Guideline1_1.1_1_1.G73,G74contain capitals and commas, sotagValueconverts the codes in a similar way and you know which value ends up in Datadog. - Cardinality. Each unique combination of metric name and tag values counts as a custom metric, and locales times page types times rules adds up. Check the usage page after the first runs, and if the count is too high, keep the
ruletag only for errors.
Now put it together: the script scans four pages at a time in one browser, sends the series in batches and writes the report. The metrics API accepts up to 500 KB per request, and 500 series stay far below that.
const targets: Target[] = [
{ url: `${SITE}/en-gb/`, locale: 'en-gb', pageType: 'home', team: 'discovery' },
{
url: `${SITE}/en-gb/login`,
locale: 'en-gb',
pageType: 'account',
team: 'account',
actions: behindLogin('en-gb', '/account'),
},
];
await mkdir('report/shots', { recursive: true });
const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
const queue = [...targets];
const results: ScanResult[] = [];
await Promise.all(
Array.from({ length: 4 }, async () => {
for (let target = queue.shift(); target; target = queue.shift()) {
results.push(await scan(browser, target));
}
}),
);
await browser.close();
const now = Math.floor(Date.now() / 1000);
const series = results.flatMap((result) => toSeries(result, now));
for (let i = 0; i < series.length; i += 500) await sendSeries(series.slice(i, i + 500));
await writeFile('report/index.html', renderReport(groupByComponent(results)));
About --no-sandbox: on Ubuntu 23.10 and later, AppArmor can block the Chrome sandbox. The Puppeteer troubleshooting page explains how to set up a sandbox, and it also says you can turn the sandbox off if you fully trust the content you open. This job opens only your own site, but if you can, follow the Puppeteer steps and keep the sandbox on.
Run it every day in GitHub Actions
The workflow runs at 05:00 UTC and publishes the report to GitHub Pages.
name: Accessibility scan
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
concurrency:
group: accessibility-scan
cancel-in-progress: false
jobs:
scan:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- run: npm ci
- run: node scan.mts
env:
DD_SITE: datadoghq.eu
DD_API_KEY: ${{ secrets.DD_API_KEY }}
SCAN_EMAIL: ${{ secrets.SCAN_EMAIL }}
SCAN_PASSWORD: ${{ secrets.SCAN_PASSWORD }}
- uses: actions/upload-pages-artifact@v5
with:
path: report
deploy:
needs: scan
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v5
Things to know about the schedule:
- Cron uses UTC by default, but GitHub Actions also lets you set a time zone for a schedule.
- Scheduled runs can start late when GitHub is busy, mostly at the start of each hour. The scan does not need to start on the minute, so that is fine here.
- In a public repository, GitHub turns off scheduled workflows after 60 days without activity.
The npm ci step also downloads the Chrome build that Puppeteer uses. In the repository settings, set the GitHub Pages source to GitHub Actions. Check who can see the report, because a GitHub Pages site is public on the internet unless your organisation uses private Pages on GitHub Enterprise Cloud. The screenshots of account pages also show what the test account sees.
Alert in Slack when errors go up
Create a metric monitor with a change alert that compares the highest error count of the last day with the day before, per locale and page type:
change(max(last_1d),1d_ago):sum:a11y.issues.count{type:error} by {locale,page_type} > 0
Use the multi-alert variables in the message and mention the Slack channel, after you have set up the Datadog Slack integration.
Accessibility errors went up on {{page_type.name}} in {{locale.name}}.
Open the report and check the components with new errors.
@slack-a11y-alerts
Add a second monitor on a11y.scan.success that alerts when the value is below 1. Turn on the no data notification in that monitor, so that you also hear about it when the job stops sending data.
In practice
For an international cosmetics retailer, we built this kind of monitor from within the client’s architecture team. Five web teams work on the retailer’s web store, which runs in many locales. The client had no accessibility metrics, and a list of errors per page did not show which component broke or which team owned it.
In June 2026, we researched the tools and chose pa11y with two rule sets: HTML_CodeSniffer for WCAG 2.0 AA and axe-core for WCAG 2.1 AA rules. Every day at 05:00, a GitHub Actions job scans 8 page types in each production locale in headless Chromium, and it can also scan pages behind a login. Each scan sends the issue count, the scan duration and the scan status to Datadog, with tags for locale, page type, team and rule. A Datadog monitor watches the error count and alerts Slack when it goes up.
The HTML report on GitHub Pages groups the issues by UI component, which the monitor finds from its CSS class names. Each component links to the team that owns it, and screenshots show the failing elements. The monitor ran in production from early July 2026. The teams gave feedback on the report, we changed the report based on that feedback, and the work was finished in September 2026. The scan works next to manual testing, because tools cannot check every WCAG criterion. You can read more in the case study on accessibility regression monitoring.
Checklist
- Run HTML_CodeSniffer and axe-core with the standard
WCAG2AA. - Set the pa11y
timeoutyourself. - Use a test account for pages behind a login and keep the credentials in secrets.
- Keep the pa11y log level below debug in CI.
- Map CSS class names to components, and components to owner teams.
- Convert rule codes to valid tag values and watch your custom metric count.
- Send a zero when a page has no errors.
- Alert on a rise in errors and on missing scan data.
- Check who can see the report on GitHub Pages.
- Keep testing by hand with a keyboard and a screen reader.
If you want this monitor for your site, see accessibility monitoring. If issues are hard to assign because components and team boundaries are unclear, see the design system and monorepo audit or contact us.
Sources
- pa11y: README
- npm: pa11y
- npm: axe-core
- npm: @pa11y/html_codesniffer
- W3C WAI: Selecting Web Accessibility Evaluation Tools
- Puppeteer: Troubleshooting
- Puppeteer: ElementHandle.screenshot
- GitHub Docs: Events that trigger workflows
- GitHub: actions/deploy-pages
- GitHub Docs: Changing the visibility of your GitHub Pages site
- Datadog: Submit metrics API
- Datadog: Getting started with tags
- Datadog: Custom metrics
- Datadog: Metric monitor
- Datadog: Slack integration