mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-25 17:22:50 +00:00
74 lines
2.5 KiB
YAML
74 lines
2.5 KiB
YAML
name: Lighthouse Report
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- docusaurus-v**
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lighthouse-report:
|
|
permissions:
|
|
pull-requests: write # for marocchino/sticky-pull-request-comment
|
|
name: Lighthouse Report
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
|
|
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
|
|
with:
|
|
node-version: lts/*
|
|
cache: yarn
|
|
|
|
- name: Install dependencies
|
|
run: yarn || yarn || yarn
|
|
|
|
- name: Build website fast
|
|
run: yarn build:website:fast
|
|
|
|
- name: Audit URLs using Lighthouse
|
|
id: lighthouse_audit
|
|
uses: treosh/lighthouse-ci-action@fcd65974f7c4c2bf0ee9d09b84d2489183c29726 # 12.6.1
|
|
with:
|
|
urls: |
|
|
http://localhost:3000
|
|
http://localhost:3000/docs/installation
|
|
http://localhost:3000/docs/category/getting-started
|
|
http://localhost:3000/blog
|
|
http://localhost:3000/blog/preparing-your-site-for-docusaurus-v3
|
|
http://localhost:3000/blog/tags/release
|
|
http://localhost:3000/blog/tags
|
|
configPath: ./.github/workflows/lighthouserc.json
|
|
uploadArtifacts: true
|
|
temporaryPublicStorage: true
|
|
|
|
- name: Format lighthouse score
|
|
id: format_lighthouse_score
|
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # 8.0.0
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const results = ${{ steps.lighthouse_audit.outputs.manifest }}
|
|
const links = ${{ steps.lighthouse_audit.outputs.links }}
|
|
const createLighthouseReport = (await import(`${process.env.GITHUB_WORKSPACE}/admin/scripts/formatLighthouseReport.js`)).default;
|
|
const comment = createLighthouseReport({ results, links });
|
|
core.setOutput("comment", comment);
|
|
|
|
- name: Add Lighthouse stats as comment
|
|
id: comment_to_pr
|
|
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # 2.9.4
|
|
with:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
number: ${{ github.event.pull_request.number }}
|
|
header: lighthouse
|
|
message: ${{ steps.format_lighthouse_score.outputs.comment }}
|