Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

lighthouse-ci-action

> 数据库
Open source

Audit URLs using Lighthouse and test performance with Lighthouse CI.

1.3K stars0 likes3 views
WebsiteGitHub

About

Audit URLs using Lighthouse and test performance with Lighthouse CI.

Lighthouse CI Action

Audit URLs using Lighthouse and test performance with Lighthouse CI.

This action integrates Lighthouse CI with Github Actions environment. Making it simple to see failed tests, upload results, run jobs in parallel, store secrets, and interpolate env variables.

It is built in collaboration between Lighthouse Team, Treo (web performance monitoring company), and many excellent contributors.

Features:

  • ✅ Audit URLs using Lighthouse v12.6
  • Test performance with Lighthouse CI assertions or performance budgets
  • See failed results in the action interface
  • Upload results to a private LHCI server, Temporary Public Storage, or as artifacts
  • ⚙️ Full control over Lighthouse CI config
  • Fast action initialization (less than 1 second)

Example

Run Lighthouse on each push to the repo, test performance budget, save results as action artifacts.

Create .github/workflows/main.yml with the list of URLs to audit using Lighthouse.

yaml
name: Lighthouse CI
on: push
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Audit URLs using Lighthouse
        uses: treosh/lighthouse-ci-action@v12
        with:
          urls: |
            https://example.com/
            https://example.com/blog
          budgetPath: ./budget.json # test performance budgets
          uploadArtifacts: true # save results as an action artifacts
          temporaryPublicStorage: true # upload lighthouse report to the temporary storage

Describe your performance budget using a budget.json.

json
[
  {
    "path": "/*",
    "resourceSizes": [
      { "resourceType": "document", "budget": 18 },
      { "resourceType": "total", "budget": 200 }
    ]
  }
]

⚙️ See this workflow in use

Recipes

Run Lighthouse and validate against Lighthouse CI assertions.

Create .github/workflows/main.yml with the list of URLs to audit and identify a lighthouserc file with configPath.

main.yml

yaml
name: Lighthouse
on: push
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Run Lighthouse on urls and validate with lighthouserc
        uses: treosh/lighthouse-ci-action@v12
        with:
          urls: 'https://exterkamp.codes/'
          configPath: './lighthouserc.json'

Make a lighthouserc.json file with LHCI assertion syntax.

lighthouserc.json

json
{ "ci": { "assert": { "assertions": { "first-contentful-paint": ["error", { "minScore": 0.6 }] } } } }

⚙️ See this workflow in use

Upload results to a private LHCI server.

Create .github/workflows/main.yml with the list of URLs to audit using lighthouse, and identify a serverBaseUrl to upload to and an token to use.

Note: use GitHub secrets to keep your server address hidden!

main.yml

yaml
name: Lighthouse
on: push
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Run Lighthouse on urls and upload data to private lhci server
        uses: treosh/lighthouse-ci-action@v12
        with:
          urls: 'https://example.com/'
          serverBaseUrl: ${{ secrets.LHCI_SERVER_URL }}
          serverToken: ${{ secrets.LHCI_SERVER_TOKEN }}

⚙️ See this workflow in use

Audit with custom Chrome options and custom Lighthouse config.

Create .github/workflows/main.yml with the list of URLs to audit and identify a lighthouserc file with configPath.

main.yml

yaml
name: Lighthouse
on: push
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Run Lighthouse on urls with lighthouserc
        uses: treosh/lighthouse-ci-action@v12
        with:
          urls: 'https://example.com/'
          configPath: './lighthouserc.json'

Chrome flags can be set directly in the lighthouserc's collect section.

lighthouserc.json

json
{ "ci": { "collect": { "numberOfRuns": 1, "settings": { "chromeFlags": "--disable-gpu --no-sandbox --no-zygote" } } } }

Custom Lighthouse config can be defined in a separate Lighthouse config using the custom Lighthouse config syntax. This is then referenced by the lighthouserc file in the configPath.

lighthouserc.json

json
{ "ci": { "collect": { "numberOfRuns": 1, "settings": { "configPath": "./lighthouse-config.js" } } } }

Then put all the custom Lighthouse config in the file referenced in the lighthouserc.

lighthouse-config.js

javascript
module.exports = {
  extends: 'lighthouse:default',
  settings: {
    emulatedFormFactor: 'desktop',
    audits: [{ path: 'metrics/first-contentful-paint', options: { scorePODR: 800, scoreMedian: 1600 } }],
  },
}

⚙️ See this workflow in use

Test a static site without having to deploy it.

Create .github/workflows/main.yml and identify a lighthouserc file with a staticDistDir config.

main.yml

yaml
name: Lighthouse
on: push
jobs:
  static-dist-dir:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Run Lighthouse against a static dist dir
        uses: treosh/lighthouse-ci-action@v12
        with:
          # no urls needed, since it uses local folder to scan .html files
          configPath: './lighthouserc.json'

lighthouserc.json

json
{ "ci": { "collect": { "staticDistDir": "./dist" } } }

Inside your staticDistDir there should be html files that make up your site. LHCI will run a simple static webserver to host the files, then run an audit against each of them. More details on this process are in the Lighthouse CI docs.

⚙️ See this workflow in use

Integrate Lighthouse CI with Netlify

It waits for Netlify to finish building a preview and then uses a built version to check performance. Hence, recipe is a composition of 2 actions: Wait for Netlify Action and Lighthouse CI Action.

…

⚙️ See this workflow in use

Use URLs interpolation to pass secrets or environment variables

URLs support interpolation of process env variables so that you can write URLs like:

yaml
name: Lighthouse CI
on: push
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Run Lighthouse and test budgets
        uses: treosh/lighthouse-ci-action@v12
        with:
          urls: |
            https://pr-$PR_NUMBER.staging-example.com/
            https://pr-$PR_NUMBER.staging-example.com/blog
          budgetPath: ./budgets.json
          temporaryPublicStorage: true
        env:
          PR_NUMBER: ${{ github.event.pull_request.number }}

⚙️ See this workflow in use

Use with a Lighthouse plugin.

Combine the field performance plugin with Github Actions.

main.yml

yaml
name: Lighthouse CI with a plugin
on: push
jobs:
  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - run: npm install # install dependencies, that includes Lighthouse plugins
      - name: Audit URLs with Field Performance Plugin
        uses: treosh/lighthouse-ci-action@v12
        with:
          urls: |
            https://www.example.com/
          configPath: '.lighthouserc.json'
          temporaryPublicStorage: true

lighthouserc.json

json
{ "ci": { "collect": { "settings": { "plugins": ["lighthouse-plugin-field-performance"] } } } }

Add a plugin as a dependency, so it's installed locally:

package.json

json
{ "devDependencies": { "lighthouse-plugin-field-performance": "^2.0.1" } }

⚙️ See this workflow in use

Use output for a powerful composition with other actions

main.yml

yaml
# Example of output usage
name: LHCI-output-webhook
on: push
jobs:
  output-webhook:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: Use output for sending data to API.
        id: LHCIAction
        uses: ./
        with:
          urls: |
            https://treo.sh/
      - name: Webhook
          uses: denar90/[email protected]
          with:
            webhookUrl: ${{secrets.ACTION_WEBHOOK_URL}}
            data: '{ "links": ${{steps.LHCIAction.outputs.links}}, "manifest": ${{steps.LHCIAction.outputs.manifest}} }'

⚙️ See this workflow in use

GitHub Action workflow on self-hosted GitHub runner (e.g. on-premise)

main.yml

yaml
name: Lighthouse CI
on: push
jobs:
  lighthouse:
    runs-on: [self-hosted, your-custom-label]
    steps:
      - uses: actions/checkout@v6
      - name: install Node.js

      - uses: browser-actions/setup-chrome@latest

      - run: chrome --version
      - uses: actions/setup-node@v5
        with:
          node-version: ${{YOUR_REQUIRED_NODE_JS_VERSION}}

      - name: Audit URLs using Lighthouse
        uses: treosh/lighthouse-ci-action@v12
        with:
          urls: |
            https://example.com/
            https://example.com/blog
        [...]

Learn more about hosted runners

Dynamically generate URLs

Use github-script or any other means to dynamically generate a list of URLs to test

main.yml

…

Explore more workflows in public examples. Submit a pull request with a new one if they don't cover your use case.

Inputs

urls

Provide the list of URLs separated by a new line. Each URL is audited using the latest version of Lighthouse and Chrome preinstalled on the environment.

yaml
urls: |
  https://example.com/
  https://example.com/blog
  https://example.com/pricing

uploadArtifacts (default: false)

Upload Lighthouse results as action artifacts to persist results. Equivalent to using actions/upload-artifact to save the artifacts with additional action steps.

yaml
uploadArtifacts: true

uploadExtraArgs

Add extra args to the upload command.

yaml
uploadExtraArgs: "--extraHeaders.Authorization='Bearer X92sEo3n1J1F0k1E9' --extraHeaders.Foo='Bar'"

temporaryPublicStorage (default: false)

Upload reports to the temporary public storage.

Note: As the

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptgithub-actionslighthouselighthouse-ciperformance-budget

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库