Potential fix for code scanning alert no. 5: Workflow does not contain permissions #95
Workflow file for this run
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| repository_dispatch: | |
| types: [paper-revised] | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - run: npm install | |
| - run: npm run build | |
| - run: node tests/quiz.test.js | |
| - name: Verify dist/index.html exists and is self-contained | |
| run: | | |
| test -f dist/index.html | |
| grep -q '<script>' dist/index.html | |
| grep -q '<style>' dist/index.html | |
| ! grep -q 'type="module"' dist/index.html | |
| ! grep -qE '<script[^>]*src=' dist/index.html | |
| ! grep -qE '^\s*import\s' dist/index.html | |
| ! grep -qE '^\s*import\s' dist/shop.html | |
| # Allow PWA manifest and apple-touch-icon links (local files only) | |
| ! grep -qE '<link[^>]*href="https?://' dist/index.html | |
| - run: npm run generate-artifacts | |
| - name: Verify paper artifacts | |
| run: | | |
| test -d paper-artifacts/actors | |
| test -d paper-artifacts/comparisons | |
| test -f paper-artifacts/actors/Conservative-Party.svg | |
| test -f paper-artifacts/actors/Conservative-Party.json | |
| test -f paper-artifacts/actors/Conservative-Party.tex | |
| test -f paper-artifacts/comparisons/uk-parties.svg | |
| test -f paper-artifacts/comparisons/wwii-figures.svg | |
| # Validate SVG is well-formed XML | |
| xmllint --noout paper-artifacts/actors/Conservative-Party.svg || true | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - run: npm install | |
| - run: npm run build | |
| - uses: actions/configure-pages@v5 | |
| - uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: dist/ | |
| - uses: actions/deploy-pages@v4 | |
| id: deployment |