Lighthouse Report #7
This file contains 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: Lighthouse Report | |
on: | |
deployment_status: | |
states: ['success'] | |
jobs: | |
generate_lighthouse_audit: | |
name: Deployment Audit | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
if: ${{ contains(fromJson('["Production – catalyst-latest", "Preview – catalyst-latest"]'), github.event.deployment_status.environment) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Lighthouse house audit on desktop | |
id: lighthouse_audit_desktop | |
uses: treosh/lighthouse-ci-action@v11 | |
with: | |
urls: | | |
${{ github.event.deployment_status.target_url }} | |
configPath: '.github/workflows/.lighthouserc-desktop.json' | |
temporaryPublicStorage: true | |
runs: 3 | |
- name: Lighthouse audit on mobile | |
id: lighthouse_audit_mobile | |
uses: treosh/lighthouse-ci-action@v11 | |
with: | |
urls: | | |
${{ github.event.deployment_status.target_url }} | |
temporaryPublicStorage: true | |
runs: 3 | |
- uses: pnpm/action-setup@v3 | |
- name: Format lighthouse score on desktop | |
id: format_lighthouse_score_desktop | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js'); | |
const lighthouseOutputs = { | |
manifest: ${{ steps.lighthouse_audit_desktop.outputs.manifest }}, | |
links: ${{ steps.lighthouse_audit_desktop.outputs.links }}, | |
preset: "desktop" | |
}; | |
const comment = lighthouseCommentMaker({ lighthouseOutputs }); | |
core.setOutput("comment", comment); | |
- name: Format lighthouse score on mobile | |
id: format_lighthouse_score_mobile | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const lighthouseCommentMaker = require('./.github/workflows/lighthouseCommentMaker.js'); | |
const lighthouseOutputs = { | |
manifest: ${{ steps.lighthouse_audit_mobile.outputs.manifest }}, | |
links: ${{ steps.lighthouse_audit_mobile.outputs.links }}, | |
preset: "mobile" | |
}; | |
const comment = lighthouseCommentMaker({ lighthouseOutputs }); | |
core.setOutput("comment", comment); | |
- name: Find pull request | |
uses: jwalton/gh-find-current-pr@v1.3.3 | |
id: finder | |
- name: Add comment to PR | |
id: comment_to_pr | |
uses: marocchino/sticky-pull-request-comment@v2.9.0 | |
with: | |
recreate: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
number: ${{ steps.finder.outputs.pr }} | |
header: lighthouse | |
message: | | |
# ⚡️🏠 Lighthouse report | |
*Lighthouse ran against ${{ github.event.deployment_status.target_url }}* | |
## 🖥️ Desktop | |
${{ steps.format_lighthouse_score_desktop.outputs.comment }} | |
## 📱 Mobile | |
${{ steps.format_lighthouse_score_mobile.outputs.comment }} |