wait for dynamic content if needed #38
This file contains hidden or 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: Accessibility Checks | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| env: | |
| # `BASE_URL` determines, relative to the root of the domain, the URL that your site is served from. | |
| # E.g., if your site lives at `https://mydomain.org/myproject`, set `BASE_URL=/myproject`. | |
| # If, instead, your site lives at the root of the domain, at `https://mydomain.org`, set `BASE_URL=''`. | |
| BASE_URL: /${{ github.event.repository.name }} | |
| jobs: | |
| axe-check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Installs | |
| run: npm install jupyter-book selenium-webdriver @axe-core/webdriverjs chromedriver http-server wait-on | |
| - name: Build Jupyter Book | |
| run: npx jupyter-book build --html | |
| - name: Run Axe Checks | |
| run: | | |
| # A. Create a subdirectory structure that matches the BASE_URL | |
| # This ensures http://localhost:8080/textbook/index.html works | |
| mkdir -p staging${BASE_URL} | |
| cp -r _build/html/* staging${BASE_URL}/ | |
| # B. Start server pointing to the staging root | |
| npx http-server staging -p 8080 -s & | |
| npx wait-on http://localhost:8080${BASE_URL}/ | |
| # C. Generate URLs including the BASE_URL prefix | |
| cd _build/html | |
| # We add the BASE_URL to the string via sed | |
| URLS=$(find . -name "*.html" -not -path "*/build/*" | sed 's|^\./||' | sed "s|^|http://localhost:8080${BASE_URL}/|" | tr '\n' ' ') | |
| cd ../.. | |
| # D. Run custom script | |
| node axe-scan.js $URLS | |
| - name: Upload Accessibility Report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: axe-report | |
| path: axe-report.json |