Add pa11y-ci action #4
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: '♿ Pa11y' | |
on: pull_request | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: npm install, build | |
run: | | |
npm install | |
npm run build | |
- name: Run pa11y-ci. | |
run: npm run pa11y-ci:sitemap 2>&1 | tee pa11y_output.txt | |
- name: Read pa11y_output file. | |
id: pa11y_output | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: ./pa11y_output.txt | |
- name: Comment on pull request. | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
message: '<details><summary>Pa11y testing results</summary>```${{ steps.pa11y_output.outputs.content }}```</details>' | |
- name: Check for pa11y failures. | |
if: contains(steps.pa11y_output.outputs.content, 'errno 2') | |
run: | | |
echo "::error::The site is failing accessibility tests. Please review the comment in the pull request or the pa11y-ci step in the workflow for details." | |
exit 1 |