GitHub Action: runs Axe accessibility tests on changed files #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check accessibility of changed content | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- gh-pages | |
pull_request: | |
permissions: | |
contents: read | |
pull-requests: read | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
check-a11y-of-changed-content: | |
name: Check accessibility of changed content | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Fetch gh-pages branch | |
run: >- | |
git fetch origin gh-pages | |
&& git branch gh-pages origin/gh-pages; | |
- name: Calculate URLs and output to JavaScript module | |
run: >- | |
chmod +x ./generate_pa11y_ci_urls_from_git_diff.sh ./url_of_post.sh ./url_of_page.sh | |
&& ./generate_pa11y_ci_urls_from_git_diff.sh gh-pages | |
>> ./pa11y-ci-urls.js; | |
- name: Log contents of resulting JavaScript module | |
run: cat ./pa11y-ci-urls.js; | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.3 | |
- name: Install gems | |
run: bundle config path vendor/bundle && bundle install | |
- name: Run the blog | |
run: bundle exec jekyll serve & | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.10.x | |
cache: npm | |
- name: Install NPM dependencies | |
run: npm ci | |
- name: Wait for blog to be running | |
run: npx wait-on http://127.0.0.1:4000 --timeout 60000 | |
- name: Find out what’s running on which ports | |
run: sudo netstat -lp | |
- name: Run pa11y (for debugging) | |
run: npx pa11y http://127.0.0.1:4000 --debug | |
- name: Run pa11y-ci | |
run: npx pa11y-ci |