# Pulled from Daniel Mundra's blog post https://accessibility.civicactions.com/posts/automated-accessibility-testing-leveraging-github-actions-and-pa11y-ci-with-axe name: pa11y tests on: [pull_request] jobs: build: name: Building site and running pa11y-ci tests runs-on: ubuntu-latest steps: - name: Checkout source. uses: actions/checkout@v2 - name: Install jekyll site dependencies. uses: ruby/setup-ruby@v1 with: ruby-version: 2.7.2 bundler-cache: true - name: Install pa11y-ci dependencies. run: npm install - name: Start up jekyll server. run: npm run start-detached - 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@main with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} message: '
Pa11y testing results ```${{ steps.pa11y_output.outputs.content }}```
' # A defect in pa11y is causing intermitent page crashes [1]. Until it is # fixed, if a page crashes during a scan, do not mark the pa11y scan as # failed. # [1] https://github.com/pa11y/pa11y-ci/issues/128 - name: Check for pa11y failures. if: "${{ contains(steps.pa11y_output.outputs.content, 'errno 2') && !contains(steps.pa11y_output.outputs.content, 'UnhandledPromiseRejectionWarning: Error: Page crashed!') }}" 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