Block new issues in CI
Add an A11yRemedy check to GitHub Actions, GitLab CI or CircleCI that scans your site and fails the build when new accessibility issues appear.
The CI gate starts a scan, waits for it, and fails the build when the scan finds new issues at or above the impact you choose. Issues that were already there don’t fail it. It doesn’t open pull requests or change your code.
Before you start
- An API key with the Trigger scans scope, saved as a secret named
A11YREMEDY_API_KEY. - The site’s ID, saved as
A11YREMEDY_SITE_ID. It’s in the site’s address in the app: app.a11yremedy.com/sites/SITE_ID. - The site should point at the environment you want to check, such as staging.
The gate
fail_on is critical, serious, moderate or minor. A serious gate fails on new serious and critical issues. Use this script in any CI that has curl and jq:
API="https://api.a11yremedy.com/api/v1"
AUTH="Authorization: Bearer ${A11YREMEDY_API_KEY}"
code=$(curl -sS -o scan.json -w '%{http_code}' -X POST -H "$AUTH" "$API/sites/${A11YREMEDY_SITE_ID}/scan")
test "$code" = "202"
scan_id=$(jq -r .id scan.json)
for _ in $(seq 1 60); do
curl -fsS -H "$AUTH" "$API/scans/${scan_id}" -o scan.json
status=$(jq -r .status scan.json)
if [ "$status" != "queued" ] && [ "$status" != "running" ]; then break; fi
sleep 15
done
test "$status" = "completed"
curl -fsS -H "$AUTH" "$API/scans/${scan_id}/gate?fail_on=serious" -o gate.json
jq . gate.json
test "$(jq -r .passed gate.json)" = "true"
The script waits up to 15 minutes. For a bigger site, raise the loop count, or lower the site’s Pages per scan.
GitHub Actions
Save the script as .github/a11yremedy-gate.sh and add a workflow:
name: Accessibility
on: pull_request
jobs:
a11yremedy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: bash .github/a11yremedy-gate.sh
env:
A11YREMEDY_API_KEY: ${{ secrets.A11YREMEDY_API_KEY }}
A11YREMEDY_SITE_ID: ${{ secrets.A11YREMEDY_SITE_ID }}
GitLab CI, CircleCI and others
Run the same script in a job with an image that has curl and jq (for example badouralix/curl-jq on GitLab, or cimg/base on CircleCI), with the two variables set as protected CI variables.
Reading the result
gate.json has the scan’s status, new_issues_by_impact (counts of critical, serious, moderate and minor issues that are new since the last scan) and passed. To see the issues themselves, open the site in A11yRemedy. Fix them, or suppress the ones you’ve checked and accepted; see Suppress an issue.
Last updated