Skip to content

Commit

Permalink
(ci): fixed lighthouse error
Browse files Browse the repository at this point in the history
  • Loading branch information
happer64bit committed Aug 5, 2024
1 parent 4479d2b commit 4f447b0
Showing 1 changed file with 25 additions and 35 deletions.
60 changes: 25 additions & 35 deletions .github/workflows/performance-monitor.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
name: Lighthouse CI
name: Lighthouse Report Generation

on:
push:
branches: [ git-workflows ]
pull_request:
branches:
- main
- dev
branches: [ git-workflows ]

jobs:
lighthouse:
name: Run Lighthouse CI
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: 'Installing deps'
run: |
yarn
npm i -g @lhci/cli@0.9.x serve
- name: Install dependencies
run: npm install
- name: 'Build Prodcution'
run: yarn build

- name: Start the Next.js app
run: npm run start &

- name: Run Lighthouse CI
run: npx lhci --config .lighthouserc.js --output html --output-path ./report.html
- name: 'Serve Prodcution Server'
run: yarn start &

- name: Upload Lighthouse report
uses: actions/upload-artifact@v3
with:
name: lighthouse-report
path: ./report.html
- name: 'Run Lighthouse tests'
continue-on-error: true
run: lhci autorun

- name: Comment on PR
uses: actions/github-script@v6
- name: 'Upload report'
uses: actions/upload-artifact@v2
if: always()
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('./report.html', 'utf8');
const pullRequest = context.issue.number;
await github.rest.issues.createComment({
...context.repo,
issue_number: pullRequest,
body: `Lighthouse report:\n\n[View Report](https://github.com/${context.repo.owner}/${context.repo.repo}/suites/${process.env.GITHUB_RUN_ID}/artifacts/1)`
});
name: lhci-reports
path: |
.lighthouseci/
# if-no-files-found: error
# if: ${{ success() && steps.lighthouse.outputs.hasHtmlReport == 'true' && steps.lighthouse.outputs.hasJsonReport == 'true' }}

0 comments on commit 4f447b0

Please sign in to comment.