|
| 1 | +name: Lighthouse CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main, develop] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lighthouse: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + |
| 15 | + - name: Setup Node.js |
| 16 | + uses: actions/setup-node@v4 |
| 17 | + with: |
| 18 | + node-version: '20' |
| 19 | + cache: 'npm' |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: npm ci |
| 23 | + |
| 24 | + - name: Build Next.js |
| 25 | + run: npm run build |
| 26 | + env: |
| 27 | + NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }} |
| 28 | + NEXT_PUBLIC_SITE_URL: https://blog.klyx.fr |
| 29 | + NEXT_PUBLIC_CALENDLY_URL: https://calendly.com/klyx-studio/call-solution-site-internet |
| 30 | + NEXT_PUBLIC_CONTACT_EMAIL: contact@klyx.fr |
| 31 | + NEXT_PUBLIC_MAIN_SITE_URL: https://klyx.fr |
| 32 | + |
| 33 | + - name: Start Next.js server |
| 34 | + run: npm run start & |
| 35 | + env: |
| 36 | + NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }} |
| 37 | + NEXT_PUBLIC_SITE_URL: https://blog.klyx.fr |
| 38 | + NEXT_PUBLIC_CALENDLY_URL: https://calendly.com/klyx-studio/call-solution-site-internet |
| 39 | + NEXT_PUBLIC_CONTACT_EMAIL: contact@klyx.fr |
| 40 | + NEXT_PUBLIC_MAIN_SITE_URL: https://klyx.fr |
| 41 | + |
| 42 | + - name: Wait for server |
| 43 | + run: npx wait-on http://localhost:3000 --timeout 60000 |
| 44 | + |
| 45 | + - name: Run Lighthouse CI |
| 46 | + uses: treosh/lighthouse-ci-action@v10 |
| 47 | + with: |
| 48 | + urls: | |
| 49 | + http://localhost:3000 |
| 50 | + http://localhost:3000/about |
| 51 | + http://localhost:3000/contact |
| 52 | + budgetPath: ./.lighthouserc.json |
| 53 | + uploadArtifacts: true |
| 54 | + temporaryPublicStorage: true |
| 55 | + |
| 56 | + - name: Comment PR with results |
| 57 | + if: github.event_name == 'pull_request' |
| 58 | + uses: actions/github-script@v7 |
| 59 | + with: |
| 60 | + script: | |
| 61 | + const results = require('./.lighthouseci/manifest.json'); |
| 62 | + const comment = `## ⚡ Lighthouse CI Results\n\nPerformance scores are available in the artifacts.`; |
| 63 | + github.rest.issues.createComment({ |
| 64 | + issue_number: context.issue.number, |
| 65 | + owner: context.repo.owner, |
| 66 | + repo: context.repo.repo, |
| 67 | + body: comment |
| 68 | + }); |
| 69 | +
|
0 commit comments