Skip to content

Commit

Permalink
feat: add Lighthouse CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thekavikumar committed Jul 31, 2024
1 parent 236f345 commit 0a457ce
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,39 @@ jobs:
- name: Install Lighthouse
run: yarn global add lighthouse

- name: Run Lighthouse on production build
id: lighthouse-production
run: lighthouse http://localhost:3000 --output html --output-path ./lighthouse-production.html --chrome-flags="--headless --no-sandbox --disable-gpu" --view

- name: Display Lighthouse report
run: cat ./lighthouse-production.json | jq
- name: Run Lighthouse on production build (HTML)
run: lighthouse http://localhost:3000 --output html --output-path ./lighthouse-production.html --chrome-flags="--headless --no-sandbox --disable-gpu"

- name: Upload Lighthouse results
uses: actions/upload-artifact@v2
with:
name: lighthouse-results
path: |
lighthouse-production.html
lighthouse-production.json
- name: Set up Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
- name: Deploy report to GitHub Pages
run: |
git clone --branch gh-pages https://github.com/${{ github.repository }} gh-pages
cp lighthouse-production.html gh-pages/
cd gh-pages
git add lighthouse-production.html
git commit -m "Deploy Lighthouse report"
git push origin gh-pages
- name: Comment with report link
uses: actions/github-script@v6
with:
script: |
const { context } = require('@actions/github');
const reportUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/lighthouse-production.html`;
const issueComment = `Lighthouse performance report is available here: [View Report](${reportUrl})`;
await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: issueComment,
});

0 comments on commit 0a457ce

Please sign in to comment.