🎄 GitHub Actions Advent Calendar

moon indicating dark mode
sun indicating light mode

Day 3: Audit websites automaticallly with Lighthouse

December 03, 2019

Google’s Lighthouse tool provides website auditing that is both built into the Chrome web browser and accessible as a Node module. With Lighthouse-CI, you can run Lighthouse in CI environments and send results to a dashboard.

Treo.sh wrote a GitHub Action called lighthouse-ci-action that wraps Lighthouse-CI into an action.

Example Usage

Their basic example showcases hitting a live site and doing some audits and then saving the results using GitHub’s upload-artifact action to save it as an artifact of the workflow.

name: Lighthouse
on: push
jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v2
with:
urls: |
https://treo.sh/
https://treo.sh/demo
- name: Save results
uses: actions/upload-artifact@v1
with:
name: lighthouse-results
path: '.lighthouseci' # This will save the Lighthouse results as .json files

As well, instead of saving as an artifact here, You could take those results and save them to any external service for later usage or use the upload parameter of this action to authenticate and send the results to a LHCI server that can provide side-by-side changes between audits to see how things change over time.