|
5 | 5 | states: ['success'] |
6 | 6 |
|
7 | 7 | env: |
8 | | - PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }} |
9 | 8 | VERCEL_PROTECTION_BYPASS: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }} |
10 | | - BIGCOMMERCE_ACCESS_TOKEN: ${{ secrets.BIGCOMMERCE_ACCESS_TOKEN }} |
11 | | - BIGCOMMERCE_STORE_HASH: ${{ secrets.BIGCOMMERCE_STORE_HASH }} |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.deployment_status.target_url }} |
| 12 | + cancel-in-progress: true |
12 | 13 |
|
13 | 14 | jobs: |
14 | | - generate-lighthouse-audit: |
15 | | - name: Lighthouse Audit |
16 | | - timeout-minutes: 30 |
17 | | - runs-on: ubuntu-latest |
| 15 | + unlighthouse-audit: |
18 | 16 | if: ${{ contains(fromJson('["Production – catalyst-canary", "Preview – catalyst-canary"]'), github.event.deployment_status.environment) }} |
| 17 | + name: Unlighthouse Audit - ${{ matrix.device }} |
| 18 | + runs-on: ubuntu-latest |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + device: [desktop, mobile] |
| 22 | + concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.deployment_status.target_url }}-${{ matrix.device }} |
| 24 | + cancel-in-progress: true |
19 | 25 |
|
20 | 26 | steps: |
21 | 27 | - name: Checkout code |
22 | 28 | uses: actions/checkout@v4 |
23 | | - |
24 | | - - name: Pull Request Details |
25 | | - id: pr_details |
26 | | - uses: actions/github-script@v7 |
27 | 29 | with: |
28 | | - script: | |
29 | | - const prData = require('./.github/workflows/pull-request-data.js'); |
30 | | - await prData({ github, context, core }); |
| 30 | + fetch-depth: 0 |
31 | 31 |
|
32 | | - - name: Lighthouse house audit on desktop |
33 | | - id: lighthouse_audit_desktop |
34 | | - uses: treosh/lighthouse-ci-action@v11 |
35 | | - with: |
36 | | - urls: | |
37 | | - ${{ github.event.deployment_status.target_url }} |
38 | | - configPath: '.github/workflows/.lighthouserc-desktop.json' |
39 | | - temporaryPublicStorage: true |
40 | | - runs: 3 |
41 | | - |
42 | | - - name: Lighthouse audit on mobile |
43 | | - id: lighthouse_audit_mobile |
44 | | - uses: treosh/lighthouse-ci-action@v11 |
45 | | - with: |
46 | | - urls: | |
47 | | - ${{ github.event.deployment_status.target_url }} |
48 | | - temporaryPublicStorage: true |
49 | | - runs: 3 |
50 | | - |
51 | | - - uses: pnpm/action-setup@v3 |
52 | | - - name: Format lighthouse score on desktop |
53 | | - id: format_lighthouse_score_desktop |
54 | | - uses: actions/github-script@v7 |
55 | | - with: |
56 | | - script: | |
57 | | - const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js'); |
58 | | -
|
59 | | - const lighthouseOutputs = { |
60 | | - manifest: ${{ steps.lighthouse_audit_desktop.outputs.manifest }}, |
61 | | - links: ${{ steps.lighthouse_audit_desktop.outputs.links }}, |
62 | | - preset: "desktop" |
63 | | - }; |
64 | | -
|
65 | | - const comment = lighthouseCommentMaker({ lighthouseOutputs }); |
66 | | - core.setOutput("comment", comment); |
67 | | -
|
68 | | - - name: Format lighthouse score on mobile |
69 | | - id: format_lighthouse_score_mobile |
70 | | - uses: actions/github-script@v7 |
71 | | - with: |
72 | | - script: | |
73 | | - const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js'); |
74 | | - |
75 | | - const lighthouseOutputs = { |
76 | | - manifest: ${{ steps.lighthouse_audit_mobile.outputs.manifest }}, |
77 | | - links: ${{ steps.lighthouse_audit_mobile.outputs.links }}, |
78 | | - preset: "mobile" |
79 | | - }; |
| 32 | + - name: Install Dependencies |
| 33 | + run: npm install @unlighthouse/cli puppeteer -g |
80 | 34 |
|
81 | | - const comment = lighthouseCommentMaker({ lighthouseOutputs }); |
82 | | - core.setOutput("comment", comment); |
| 35 | + - name: Unlighthouse audit on ${{ matrix.device }} |
| 36 | + run: unlighthouse-ci --site ${{ github.event.deployment_status.target_url }} --${{ matrix.device }} --disable-robots-txt --extra-headers x-vercel-protection-bypass=$VERCEL_PROTECTION_BYPASS,x-vercel-set-bypass-cookie=true |
83 | 37 |
|
84 | | - - name: Add comment to PR |
85 | | - id: comment_to_pr |
86 | | - uses: marocchino/sticky-pull-request-comment@v2.9.0 |
87 | | - if: ${{ steps.pr_details.outputs.pr }} |
| 38 | + - name: Upload ${{ matrix.device }} audit |
| 39 | + if: failure() || success() |
| 40 | + uses: actions/upload-artifact@v4 |
88 | 41 | with: |
89 | | - recreate: true |
90 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
91 | | - number: ${{ steps.pr_details.outputs.pr }} |
92 | | - header: lighthouse |
93 | | - message: | |
94 | | - # ⚡️🏠 Lighthouse report |
95 | | - |
96 | | - *Lighthouse ran against ${{ github.event.deployment_status.target_url }}* |
97 | | - |
98 | | - ## 🖥️ Desktop |
99 | | - |
100 | | - ${{ steps.format_lighthouse_score_desktop.outputs.comment }} |
101 | | - |
102 | | - ## 📱 Mobile |
103 | | - |
104 | | - ${{ steps.format_lighthouse_score_mobile.outputs.comment }} |
| 42 | + name: unlighthouse-${{ matrix.device }}-report |
| 43 | + path: './.unlighthouse/' |
| 44 | + include-hidden-files: 'true' |
0 commit comments