fix #997
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: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| install: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - run: npm ci | |
| - uses: actions/cache/save@v4 | |
| with: | |
| path: node_modules | |
| key: node-modules-${{ hashFiles('package-lock.json') }} | |
| check: | |
| needs: install | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - uses: actions/cache/restore@v4 | |
| with: | |
| path: node_modules | |
| key: node-modules-${{ hashFiles('package-lock.json') }} | |
| - run: npm run lint | |
| - run: npx tsc --noEmit | |
| - run: npm test -- --coverage | |
| - name: Generate coverage badge | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| PCT=$(node -e "const c=require('./coverage/coverage-summary.json');console.log(c.total.statements.pct)") | |
| if [ "$(echo "$PCT >= 80" | bc)" -eq 1 ]; then COLOR="brightgreen" | |
| elif [ "$(echo "$PCT >= 60" | bc)" -eq 1 ]; then COLOR="yellow" | |
| else COLOR="red"; fi | |
| mkdir -p badge | |
| echo "{\"schemaVersion\":1,\"label\":\"coverage\",\"message\":\"${PCT}%\",\"color\":\"${COLOR}\"}" > badge/coverage.json | |
| - name: Push badge to gh-pages | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| cp badge/coverage.json /tmp/coverage.json | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin gh-pages | |
| git checkout gh-pages | |
| cp /tmp/coverage.json coverage.json | |
| git add coverage.json | |
| git diff --cached --quiet || git commit -m "update coverage badge" | |
| git push origin gh-pages | |
| changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| blog: ${{ steps.filter.outputs.blog }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| blog: | |
| - 'content/blog/**' | |
| links: | |
| needs: changes | |
| if: needs.changes.outputs.blog == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/cache@v4 | |
| with: | |
| path: .lycheecache | |
| key: lychee-${{ hashFiles('content/blog/*.mdx') }} | |
| restore-keys: lychee- | |
| - uses: lycheeverse/lychee-action@v2 | |
| with: | |
| args: >- | |
| --no-progress | |
| --base https://www.itefficience.com | |
| --exclude 'mailto:' | |
| --exclude 'itefficience\.com' | |
| --cache | |
| --max-cache-age 7d | |
| --timeout 30 | |
| --max-retries 3 | |
| --accept 200,204,301,302,403,429 | |
| content/blog/*.mdx | |
| build: | |
| needs: install | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - uses: actions/cache/restore@v4 | |
| with: | |
| path: node_modules | |
| key: node-modules-${{ hashFiles('package-lock.json') }} | |
| - uses: actions/cache@v4 | |
| with: | |
| path: .next/cache | |
| key: nextjs-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/*.ts', '**/*.tsx') }} | |
| restore-keys: nextjs-${{ hashFiles('package-lock.json') }}- | |
| - run: npm run build |