Skip to content

tooling/lighthouse

tooling/lighthouse #38

Workflow file for this run

name: Lighthouse CI
on:
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Install Lighthouse CI
run: npm install -g @lhci/cli
- name: Start HTTP Server
run: npx http-server ./dist -p 4173 &
shell: bash
- name: Wait for HTTP Server to start
run: sleep 10
- name: Run Lighthouse CI
id: lhci
run: |
lhci autorun --config=.lighthouserc.js
echo "::set-output name=report_url::$(<some-command-to-get-url>)"
continue-on-error: true
- name: Post Comment on PR
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
${{ steps.lhci.outcome == 'failure' && '❌ Lighthouse checks failed. Please review the Lighthouse report in the Artifacts.' || '✅ Lighthouse checks passed successfully!' }}
Report URL: [View Lighthouse Report](${{ steps.lhci.outputs.report_url }})
token: ${{ secrets.GITHUB_TOKEN }}
- name: Fail the Workflow if Lighthouse Failed
if: steps.lhci.outcome == 'failure'
run: exit 1