Refactor accessibility scan workflow configuration #66
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: Publish website | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build_and_deploy: | |
| name: Build & deploy website | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'Orange-OpenSource/Tota11ylost' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| - name: Generate firebaseConfig.js | |
| run: | | |
| echo "window.env = {" > ./src/firebaseConfig.js | |
| echo " FIREBASE_API_KEY: '${{ secrets.FIREBASE_API_KEY }}'," >> ./src/firebaseConfig.js | |
| echo " FIREBASE_AUTH_DOMAIN: '${{ secrets.FIREBASE_AUTH_DOMAIN }}'," >> ./src/firebaseConfig.js | |
| echo " FIREBASE_PROJECT_ID: '${{ secrets.FIREBASE_PROJECT_ID }}'," >> ./src/firebaseConfig.js | |
| echo " FIREBASE_STORAGE_BUCKET: '${{ secrets.FIREBASE_STORAGE_BUCKET }}'," >> ./src/firebaseConfig.js | |
| echo " FIREBASE_MESSAGING_SENDER_ID: '${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}'," >> ./src/firebaseConfig.js | |
| echo " FIREBASE_APP_ID: '${{ secrets.FIREBASE_APP_ID }}'," >> ./src/firebaseConfig.js | |
| echo " FIREBASE_MEASUREMENT_ID: '${{ secrets.FIREBASE_MEASUREMENT_ID }}'" >> ./src/firebaseConfig.js | |
| echo "};" >> ./src/firebaseConfig.js | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3.6.4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./src | |
| cname: tota11ylost.orange.com | |
| wait_for_deployment: | |
| name: Wait for deployed website | |
| needs: build_and_deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Wait for GitHub Pages | |
| run: | | |
| set -eu | |
| for attempt in $(seq 1 30); do | |
| if curl \ | |
| --fail \ | |
| --silent \ | |
| --show-error \ | |
| --output /dev/null \ | |
| "https://tota11ylost.orange.com"; then | |
| echo "Website is reachable." | |
| exit 0 | |
| fi | |
| echo "Website not ready yet: attempt ${attempt}/30" | |
| sleep 10 | |
| done | |
| echo "Website did not become reachable before timeout." | |
| exit 1 | |
| accessibility: | |
| name: Accessibility scan | |
| needs: wait_for_deployment | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| container: | |
| image: mcr.microsoft.com/playwright:v1.60.0-noble | |
| env: | |
| A11Y_URLS: "https://tota11ylost.orange.com" | |
| A11Y_TEST_TYPE: "essentials" | |
| A11Y_TARGET: "web" | |
| steps: | |
| - name: Download tota11y-scan from GitLab | |
| env: | |
| GITLAB_TOKEN: ${{ secrets.TOTA11Y_GITLAB_TOKEN }} | |
| run: | | |
| set -eu | |
| mkdir .tota11y-scan | |
| curl \ | |
| --fail \ | |
| --silent \ | |
| --show-error \ | |
| --location \ | |
| --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ | |
| "https://gitlab.tech.orange/api/v4/projects/574357/repository/archive.tar.gz?sha=v1.0.46" \ | |
| --output tota11y-scan.tar.gz | |
| tar \ | |
| --extract \ | |
| --gzip \ | |
| --file tota11y-scan.tar.gz \ | |
| --directory .tota11y-scan \ | |
| --strip-components=1 | |
| - name: Configure private npm registry | |
| working-directory: .tota11y-scan | |
| env: | |
| GITLAB_TOKEN: ${{ secrets.TOTA11Y_GITLAB_TOKEN }} | |
| run: | | |
| set -eu | |
| npm config set \ | |
| @tota11y-scan:registry \ | |
| "https://gitlab.tech.orange/api/v4/projects/574357/packages/npm/" | |
| npm config set -- \ | |
| "//gitlab.tech.orange/api/v4/projects/574357/packages/npm/:_authToken" \ | |
| "${GITLAB_TOKEN}" | |
| - name: Install scanner | |
| working-directory: .tota11y-scan | |
| run: | | |
| npm ci | |
| node scripts/patch-engine-auth.js | |
| npx playwright install --with-deps chromium | |
| - name: Run accessibility scan | |
| working-directory: .tota11y-scan | |
| run: npm run ci:a11y | |
| - name: Upload accessibility reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: accessibility-reports | |
| path: | | |
| .tota11y-scan/a11y-report.json | |
| .tota11y-scan/reports | |
| if-no-files-found: warn | |
| retention-days: 30 |