47 / 95 · 05 Performance & Chaos Engineering · Web Vitals Performance Gates in CI← prev⊞ allnext →☰ Read as one page
8.2GitHub Actions: Complete Performance Budget Workflow
# .github/workflows/performance-budget.yml
name: Performance Budget Check
on:
pull_request:
branches: [main]
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Install dependencies and build
run: npm ci && npm run build
- name: Deploy preview
run: npm run deploy:preview
env:
PREVIEW_TOKEN: ${{ secrets.PREVIEW_TOKEN }}
- name: Run Lighthouse CI
uses: treosh/lighthouse-ci-action@v11
with:
configPath: ./lighthouserc.json
uploadArtifacts: true
temporaryPublicStorage: true
- name: Check bundle size budget
run: npx bundlesize --config bundlesize.config.json
- name: Check API response time budget
run: |
FAILED=0
for endpoint in "/api/products" "/api/cart" "/api/search?q=test"; do
RESPONSE_TIME=$(curl -o /dev/null -s -w '%{time_total}' \
"https://staging.example.com${endpoint}")
echo "$endpoint: ${RESPONSE_TIME}s"
if (( $(echo "$RESPONSE_TIME > 0.5" | bc -l) )); then
echo "FAIL: $endpoint exceeded 500ms budget (actual: ${RESPONSE_TIME}s)"
FAILED=1
fi
done
if [ "$FAILED" -eq 1 ]; then
exit 1
fi
- name: Post results as PR comment
if: always()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: performance-budget
path: lighthouse-results-summary.md