Performance #137
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: Performance | |
| on: | |
| schedule: | |
| - cron: '0 4 * * *' # 04:00 UTC daily (after newsletter cron at 03:00) | |
| pull_request: | |
| paths: | |
| - 'src/**' | |
| - 'public/**' | |
| - 'next.config.*' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'lighthouserc.json' | |
| - 'budget.json' | |
| - '.github/workflows/perf.yml' | |
| workflow_dispatch: | |
| jobs: | |
| lhci: | |
| name: Lighthouse CI | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - run: npm ci | |
| - name: Run Lighthouse CI | |
| id: lhci | |
| uses: treosh/lighthouse-ci-action@v12 | |
| with: | |
| configPath: './lighthouserc.json' | |
| uploadArtifacts: true | |
| temporaryPublicStorage: true | |
| - name: Open issue on regression | |
| if: failure() && github.event_name == 'schedule' | |
| uses: peter-evans/create-issue-from-file@v5 | |
| with: | |
| title: "[Perf] LHCI regression detected — run ${{ github.run_id }}" | |
| content-filepath: ./.github/perf-issue-template.md | |
| labels: | | |
| performance | |
| automated | |
| - name: Email alert on regression | |
| if: failure() && github.event_name == 'schedule' | |
| env: | |
| RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }} | |
| ADMIN_EMAIL: ${{ secrets.ADMIN_EMAIL }} | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| run: | | |
| curl -fsS -X POST https://api.resend.com/emails \ | |
| -H "Authorization: Bearer $RESEND_API_KEY" \ | |
| -H "Content-Type: application/json" \ | |
| -d "$(jq -n --arg url "$RUN_URL" --arg to "$ADMIN_EMAIL" '{ | |
| from: "AI UX Daily <imran@aiuxdesign.guide>", | |
| to: [$to], | |
| subject: "[Perf] LHCI nightly regression detected", | |
| html: ("<p>The nightly Lighthouse CI run failed against budget.json.</p>" + | |
| "<p><a href=\"" + $url + "\">Open the failing run</a></p>" + | |
| "<p>The auto-opened GitHub issue has the investigation checklist.</p>") | |
| }')" |