🔍 CodeQL #97
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
| # Reusable workflow for code analysis; to eject, you can replace this file with | |
| # https://github.com/ryansonshine/ryansonshine/blob/main/.github/workflows/codeql-analysis.yml | |
| name: 🔍 CodeQL | |
| permissions: | |
| security-events: write | |
| actions: read | |
| contents: read | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| - cron: '36 7 * * 6' | |
| jobs: | |
| analyze: | |
| uses: ryansonshine/ryansonshine/.github/workflows/codeql-analysis.yml@main | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # allow committing the refreshed coverage badge | |
| steps: | |
| - name: ⬇️ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: 🟦 Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Clean npm cache | |
| run: | | |
| rm -rf node_modules | |
| npm cache clean --force | |
| - name: 📦 Install dependencies | |
| run: npm install | |
| - name: Run jest | |
| run: npx jest --coverage | |
| - name: 🔨 Build (for bundle size) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: npm run build | |
| # Self-hosted badges: regenerate coverage (from jest) and minzipped size | |
| # (from the built ESM bundle) and commit them, so the README badges are | |
| # always accurate without depending on Codecov / bundlejs / bundlephobia. | |
| - name: 🏷️ Refresh coverage & size badges | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| node scripts/gen-coverage-badge.mjs | |
| node scripts/gen-size-badge.mjs | |
| git config user.name "Khaled Alam" | |
| git config user.email "khaledalam.net@gmail.com" | |
| git add .github/badges/coverage.json .github/badges/size.json | |
| if git diff --cached --quiet; then | |
| echo "Badges unchanged." | |
| else | |
| git commit -m "chore: update coverage & size badges [skip ci]" | |
| git push | |
| fi |