mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-29 05:12:52 +00:00
63 lines
2.3 KiB
YAML
63 lines
2.3 KiB
YAML
name: Lighthouse Report
|
|
|
|
on:
|
|
pull_request_target:
|
|
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@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
|
|
- name: Wait for the Netlify Preview
|
|
uses: jakepartusch/wait-for-netlify-action@f1e137043864b9ab9034ae3a5adc1c108e3f1a48 # v1
|
|
id: netlify
|
|
with:
|
|
site_name: docusaurus-2
|
|
max_timeout: 600
|
|
- name: Audit URLs using Lighthouse
|
|
id: lighthouse_audit
|
|
uses: treosh/lighthouse-ci-action@03becbfc543944dd6e7534f7ff768abb8a296826 # 10.1.0
|
|
with:
|
|
urls: |
|
|
https://deploy-preview-$PR_NUMBER--docusaurus-2.netlify.app/
|
|
https://deploy-preview-$PR_NUMBER--docusaurus-2.netlify.app/docs/installation
|
|
configPath: ./.github/workflows/lighthouserc.json
|
|
uploadArtifacts: true
|
|
temporaryPublicStorage: true
|
|
env:
|
|
PR_NUMBER: ${{ github.event.pull_request.number}}
|
|
- name: Format lighthouse score
|
|
id: format_lighthouse_score
|
|
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
|
|
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@f61b6cf21ef2fcc468f4345cdfcc9bda741d2343 # 2.6.2
|
|
with:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
number: ${{ github.event.pull_request.number }}
|
|
header: lighthouse
|
|
message: ${{ steps.format_lighthouse_score.outputs.comment }}
|