|
| 1 | +name: Lighthouse audit |
| 2 | + |
| 3 | +on: push |
| 4 | + #push: |
| 5 | + # branches: |
| 6 | + # - master |
| 7 | + |
| 8 | +env: |
| 9 | + STORE_URL: ${{ vars.STORE_URL }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + #wait-for-circleci: |
| 13 | + # runs-on: ubuntu-latest |
| 14 | + # steps: |
| 15 | + # - name: Wait for CircleCI jobs to complete |
| 16 | + # uses: lewagon/wait-on-check-action@v1.3.4 |
| 17 | + # with: |
| 18 | + # ref: ${{ github.sha }} |
| 19 | + # check-name: 'ci/circleci: release' |
| 20 | + # repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
| 22 | + lighthouse-audit: |
| 23 | + #needs: wait-for-circleci |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Check out code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Set up Node.js |
| 30 | + uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: 22 |
| 33 | + |
| 34 | + - name: Install dependencies |
| 35 | + run: npm ci |
| 36 | + |
| 37 | + - name: Get PR details |
| 38 | + uses: jwalton/gh-find-current-pr@v1 |
| 39 | + id: pr_details |
| 40 | + |
| 41 | + - name: Run Lighthouse audit |
| 42 | + id: lighthouse_audit |
| 43 | + uses: treosh/lighthouse-ci-action@v11 |
| 44 | + with: |
| 45 | + urls: ${{ env.STORE_URL }}/checkout |
| 46 | + configPath: ./scripts/lighthouse/lighthouserc.js |
| 47 | + uploadArtifacts: true |
| 48 | + temporaryPublicStorage: true |
| 49 | + runs: 1 |
| 50 | + |
| 51 | + - name: Format Lighthouse results |
| 52 | + id: format_lighthouse_results |
| 53 | + uses: actions/github-script@v7 |
| 54 | + with: |
| 55 | + script: | |
| 56 | + const formatResults = require('./scripts/lighthouse/format-results.js'); |
| 57 | + const comment = formatResults({ |
| 58 | + manifest: ${{ steps.lighthouse_audit.outputs.manifest }}, |
| 59 | + links: ${{ steps.lighthouse_audit.outputs.links }}, |
| 60 | + }); |
| 61 | +
|
| 62 | + core.setOutput("comment", comment); |
| 63 | +
|
| 64 | + - name: Post Lighthouse results to PR |
| 65 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 66 | + with: |
| 67 | + header: Lighthouse audit results |
| 68 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + recreate: true |
| 70 | + number: ${{ steps.pr_details.outputs.number }} |
| 71 | + message: ${{ steps.format_lighthouse_results.outputs.comment }} |
| 72 | + |
0 commit comments