Merge pull request #7 from data-6-berkeley/a11y-fixes #27
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 (With Render) | |
| on: | |
| push: | |
| branches-ignore: | |
| - gh-pages | |
| workflow_dispatch: | |
| env: | |
| PRODUCTION_URL: "https://data6.org/notes/" | |
| # must match the end of PRODUCTION_URL | |
| # leave blank if at root | |
| SITE_SUBDIR: "notes" | |
| jobs: | |
| axe-audit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout Code | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # 2. Setup Quarto | |
| - name: Set up Quarto | |
| uses: quarto-dev/quarto-actions/setup@v2 | |
| # 3. Setup Node.js (for Axe and http-server) | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| # 4. Install Python dependencies | |
| - name: Install Python dependencies | |
| run: pip install -r requirements.txt | |
| # 5. Render the Site | |
| - name: Render Quarto Site | |
| env: | |
| GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} | |
| run: quarto render | |
| # 6. Install Tools | |
| - name: Install Axe and Server | |
| run: npm install -g @axe-core/cli http-server | |
| # 7. Start Local Server (Background Process) | |
| - name: Start Local Server | |
| run: | | |
| # We create a 'public/notes' folder so the local server | |
| # mimics the production path structure exactly. | |
| mkdir -p public/${{ env.SITE_SUBDIR }} | |
| cp -r _site/* public/${{ env.SITE_SUBDIR }}/ | |
| # Serve the 'public' folder on port 3000 | |
| npx http-server ./public -p 3000 > /dev/null 2>&1 & | |
| sleep 5 | |
| # 8. Run Axe Scan | |
| - name: Run Accessibility Scan | |
| id: axe-scan | |
| run: | | |
| # Swap the Production URL for Localhost + Subdirectory | |
| # e.g. https://data6.org/notes -> http://localhost:3000/notes | |
| LOCAL_URL="http://localhost:3000/${{ env.SITE_SUBDIR }}/" | |
| URLS=$(cat _site/sitemap.xml | \ | |
| sed -n 's/.*<loc>\(.*\)<\/loc>.*/\1/p' | \ | |
| sed "s|${{ env.PRODUCTION_URL }}|$LOCAL_URL|" | \ | |
| tr '\n' ' ') | |
| echo "Scanning the following pages:" | |
| echo "$URLS" | |
| # Run Axe | |
| axe $URLS \ | |
| --tags wcag2a,wcag2aa,wcag21a,wcag21aa \ | |
| --save axe-report.json \ | |
| --exit | |
| # 9. Upload Report (Runs even if Step 8 fails) | |
| - name: Upload Accessibility Report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: axe-report | |
| path: axe-report.json |