API & IntegrationsDocumentation
API: CI/CD Integration
Integrate accessibility scanning into GitHub Actions and other CI/CD pipelines.
Overview
Run automated accessibility scans on every deploy using the Ablelytics REST API.
A typical CI workflow: trigger a scan after deployment → poll until done → fail the build if critical issues are found.
GitHub Actions Workflow
Add the following workflow to .github/workflows/accessibility.yml:
name: Accessibility Scan
on:
push:
branches: [main]
workflow_dispatch:
jobs:
a11y-scan:
runs-on: ubuntu-latest
steps:
- name: Start accessibility scan
id: scan
run: |
RESPONSE=$(curl -s -X POST \
-H "x-api-key: ${{ secrets.ABLELYTICS_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{"type":"full"}' \
https://api.ablelytics.com/v1/projects/${{ vars.ABLELYTICS_PROJECT_ID }}/scans)
RUN_ID=$(echo $RESPONSE | jq -r '.data.runId')
PAGES=$(echo $RESPONSE | jq -r '.data.pagesCount')
echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT
echo "Queued scan for $PAGES pages (run: $RUN_ID)"
- name: Wait for scan to complete
id: result
run: |
RUN_ID="${{ steps.scan.outputs.run_id }}"
while true; do
RESP=$(curl -s \
-H "x-api-key: ${{ secrets.ABLELYTICS_API_KEY }}" \
https://api.ablelytics.com/v1/runs/$RUN_ID)
STATUS=$(echo $RESP | jq -r '.data.status')
CRITICAL=$(echo $RESP | jq -r '.data.stats.critical // 0')
echo "Status: $STATUS | Critical: $CRITICAL"
if [ "$STATUS" = "done" ]; then
echo "critical=$CRITICAL" >> $GITHUB_OUTPUT
break
fi
if [ "$STATUS" = "failed" ]; then
echo "Scan failed" && exit 1
fi
sleep 10
done
- name: Fail on critical issues
if: steps.result.outputs.critical != '0'
run: |
echo "Found ${{ steps.result.outputs.critical }} critical accessibility issues"
exit 1Required Secrets & Variables
- ABLELYTICS_API_KEY (Secret) — your API key from Workspace → API Settings.
- ABLELYTICS_PROJECT_ID (Variable) — the project ID to scan. Find it in the project URL.
Node.js Script
Use this script for non-GitHub environments or custom orchestration:
#!/usr/bin/env node
const API_KEY = process.env.ABLELYTICS_API_KEY;
const PROJECT_ID = process.env.ABLELYTICS_PROJECT_ID;
const BASE = 'https://api.ablelytics.com/v1';
const HEADERS = { 'x-api-key': API_KEY, 'Content-Type': 'application/json' };
async function run() {
// 1. Start scan
const scanRes = await fetch(BASE + '/projects/' + PROJECT_ID + '/scans', {
method: 'POST', headers: HEADERS,
body: JSON.stringify({ type: 'full' }),
});
const { data: { runId, pagesCount } } = await scanRes.json();
console.log('Scan queued:', runId, '(' + pagesCount + ' pages)');
// 2. Poll until done
let run;
do {
await new Promise(r => setTimeout(r, 8000));
const pollRes = await fetch(BASE + '/runs/' + runId, { headers: HEADERS });
run = (await pollRes.json()).data;
console.log('Status:', run.status, run.pagesScanned + '/' + run.pagesTotal);
} while (run.status === 'queued' || run.status === 'running');
// 3. Exit non-zero if critical issues found
if (run.status === 'failed') process.exit(1);
if (run.stats?.critical > 0) {
console.error('Critical issues found:', run.stats.critical);
process.exit(1);
}
console.log('Scan passed — no critical issues.');
}
run().catch(err => { console.error(err); process.exit(1); });Tips
- Store ABLELYTICS_API_KEY as an encrypted secret, never in plain text.
- Scope scans to a page set for faster CI checks on critical user flows.
- Consider running full scans on a schedule (nightly) rather than on every push.
- Use the issues endpoint after a scan to programmatically triage new regressions.