mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-31 23:54:25 +00:00
* added lighthouse CI removed wait for Netlify action corrected Netlify deploy urls corrected sitename corrected sitename * removed bootstrap and blog-only urls * upload results to public storage * added lighthousesrc.json * corrected configPath * corrected robots-txt assertion * corrected syntax for lighthousesrc * tried different audit * corrected all audits for lighthouse * added is-crawlable audit to skip * added lighthouse stats commit to action * Fixed Lighthouse yml syntax * Fixed lighthouse yml syntax(2) * trying comment * trying yaml syntax * test logging * trying to see a log * logging.... * corrected audit step id * Corrected token * changed comment number from issue to PR * trying different message * corrected message * added offline-start-url to skip audits * added start-url to skip fields * added offline-starts-url
66 lines
2.6 KiB
YAML
66 lines
2.6 KiB
YAML
name: Lighthouse CI
|
|
on: pull_request
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Use Node.js 12.x
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 12.x
|
|
- name: Install and Build
|
|
run: |
|
|
yarn install
|
|
yarn build
|
|
- name: Wait for the Netlify Preview
|
|
uses: jakepartusch/wait-for-netlify-action@v1
|
|
id: netlify
|
|
with:
|
|
site_name: 'docusaurus-2'
|
|
- name: Audit URLs using Lighthouse
|
|
id: lighthouse_audit
|
|
uses: treosh/lighthouse-ci-action@v3
|
|
with:
|
|
urls: |
|
|
https://deploy-preview-$PR_NUMBER--docusaurus-2.netlify.app/classic/
|
|
configPath: ./.github/workflows/lighthousesrc.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@v3
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
|
|
const links = ${{ steps.lighthouse_audit.outputs.links }}
|
|
const formatResult = (res) => Math.round((res * 100))
|
|
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
|
|
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
|
|
const comment = [
|
|
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
|
|
'| Category | Score |',
|
|
'| --- | --- |',
|
|
`| ${score(result.performance)} Performance | ${result.performance} |`,
|
|
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
|
|
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
|
|
`| ${score(result.seo)} SEO | ${result.seo} |`,
|
|
`| ${score(result.pwa)} PWA | ${result.pwa} |`,
|
|
' ',
|
|
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
|
|
].join('\n')
|
|
core.setOutput("comment", comment);
|
|
|
|
- name: Add Lighthouse stats as comment
|
|
id: comment_to_pr
|
|
uses: marocchino/sticky-pull-request-comment@v2.0.0
|
|
with:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
number: ${{ github.event.pull_request.number }}
|
|
header: lighthouse
|
|
message: ${{ steps.format_lighthouse_score.outputs.comment }}
|