Skip to content

chore(other): CHECKOUT-9275 Add Github action to run Lighthouse on ev… #16

chore(other): CHECKOUT-9275 Add Github action to run Lighthouse on ev…

chore(other): CHECKOUT-9275 Add Github action to run Lighthouse on ev… #16

name: Lighthouse audit
on: push
#push:
# branches:
# - master
env:
STORE_URL: ${{ vars.STORE_URL }}
jobs:
#wait-for-circleci:
# runs-on: ubuntu-latest
# steps:
# - name: Wait for CircleCI jobs to complete
# uses: lewagon/wait-on-check-action@v1.3.4
# with:
# ref: ${{ github.sha }}
# check-name: 'ci/circleci: release'
# repo-token: ${{ secrets.GITHUB_TOKEN }}
lighthouse-audit:
#needs: wait-for-circleci
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
run: npm ci
- name: Get PR details
uses: jwalton/gh-find-current-pr@v1
id: pr_details
- name: Run Lighthouse audit on desktop
id: lighthouse_audit_desktop
uses: treosh/lighthouse-ci-action@v11
with:
urls: ${{ env.STORE_URL }}/checkout
configPath: ./scripts/lighthouse/lighthouserc-desktop.json
uploadArtifacts: true
temporaryPublicStorage: true
runs: 3
- name: Run Lighthouse audit on mobile
id: lighthouse_audit_mobile
uses: treosh/lighthouse-ci-action@v11
with:
urls: ${{ env.STORE_URL }}/checkout
configPath: ./scripts/lighthouse/lighthouserc-mobile.json
uploadArtifacts: true
temporaryPublicStorage: true
runs: 3
- name: Format Lighthouse results
id: format_lighthouse_results
uses: actions/github-script@v7
with:
script: |
const formatResults = require('./scripts/lighthouse/format-results.js');
const comment = formatResults({
desktop: {
manifest: ${{ steps.lighthouse_audit_desktop.outputs.manifest }},
links: ${{ steps.lighthouse_audit_desktop.outputs.links }},
},
mobile: {
manifest: ${{ steps.lighthouse_audit_mobile.outputs.manifest }},
links: ${{ steps.lighthouse_audit_mobile.outputs.links }},
},
});
core.setOutput("comment", comment);
- name: Post Lighthouse results to PR
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Lighthouse audit results
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
recreate: true
number: ${{ steps.pr_details.outputs.number }}
message: ${{ steps.format_lighthouse_results.outputs.comment }}