Skip to content

feat: GitHub Action wrapper #80

Description

@nucliweb

Goal

A composite GitHub Action that wraps the CLI so any repository can measure performance in CI without manual setup.

Action definition

File: .github/actions/webperf-snippets/action.yml

name: webperf-snippets
description: Run webperf-snippets headlessly and gate on performance budgets
inputs:
  url:
    description: URL to measure
    required: true
  workflow:
    description: Workflow to run (core-web-vitals, loading, audit)
    default: core-web-vitals
  budget-lcp:
    description: LCP budget in ms. Exit 1 if exceeded.
    default: "2500"
  budget-cls:
    description: CLS budget. Exit 1 if exceeded.
    default: "0.1"
outputs:
  markdown:
    description: Formatted results as markdown
    value: ${{ steps.run.outputs.markdown }}
runs:
  using: composite
  steps:
    - run: npm install --no-save webperf-snippets playwright
      shell: bash
    - run: npx playwright install --with-deps chromium
      shell: bash
    - id: run
      shell: bash
      run: |
        RESULT=$(npx webperf-snippets ${{ inputs.url }} \
          --workflow ${{ inputs.workflow }} \
          --budget-lcp ${{ inputs.budget-lcp }} \
          --budget-cls ${{ inputs.budget-cls }} \
          --markdown)
        echo "markdown<<EOF" >> $GITHUB_OUTPUT
        echo "$RESULT" >> $GITHUB_OUTPUT
        echo "EOF" >> $GITHUB_OUTPUT

Usage in a consumer repository

- uses: nucliweb/webperf-snippets/.github/actions/webperf-snippets@main
  with:
    url: https://staging.example.com
    budget-lcp: 2500

- uses: actions/github-script@v7
  with:
    script: |
      github.rest.issues.createComment({
        issue_number: context.issue.number,
        body: `${{ steps.webperf.outputs.markdown }}`
      })

Files

  • .github/actions/webperf-snippets/action.yml — new file

Acceptance criteria

  • Works in an external repo without extra configuration
  • markdown output renders correctly when posted as a PR comment
  • Action documented in README with a complete usage example

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestv0.3Milestone v0.3

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions