From 224aadcabd58402df649bcf11f80db7209d849ed Mon Sep 17 00:00:00 2001 From: tehw0lf Date: Wed, 24 Jun 2026 20:55:16 +0200 Subject: [PATCH] feat(lighthouse): add reusable lighthouse audit workflow --- .github/workflows/lighthouse-scan.yml | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/lighthouse-scan.yml diff --git a/.github/workflows/lighthouse-scan.yml b/.github/workflows/lighthouse-scan.yml new file mode 100644 index 0000000..4df80ca --- /dev/null +++ b/.github/workflows/lighthouse-scan.yml @@ -0,0 +1,68 @@ +name: lighthouse scan + +on: + workflow_call: + inputs: + target_url: + description: "url of the running application to audit" + required: true + type: string + urls: + description: "additional urls to audit as json array (e.g. '[\"https://example.com/about\"]')" + default: "" + required: false + type: string + runner: + description: "workflow-runner" + default: "ubuntu-latest" + required: false + type: string + outputs: + lighthouse_result: + description: "lighthouse scan result" + value: ${{ jobs.lighthouse.outputs.lighthouse_result }} + +jobs: + lighthouse: + name: lighthouse audit + runs-on: ${{ inputs.runner }} + timeout-minutes: 15 + permissions: + contents: read + issues: write + outputs: + lighthouse_result: ${{ steps.audit.outcome }} + steps: + - uses: actions/checkout@v6 + + - name: build urls list + id: urls + run: | + BASE_URL="${{ inputs.target_url }}" + EXTRA='${{ inputs.urls }}' + if [ -n "$EXTRA" ]; then + URLS=$(echo "$EXTRA" | jq -c ". + [\"$BASE_URL\"]") + else + URLS="[\"$BASE_URL\"]" + fi + echo "urls=$URLS" >> $GITHUB_OUTPUT + + - name: run lighthouse + id: audit + uses: treosh/lighthouse-ci-action@v12 + with: + urls: ${{ steps.urls.outputs.urls }} + uploadArtifacts: true + temporaryPublicStorage: true + + - name: format report summary + if: always() && steps.audit.outcome != 'skipped' + run: | + echo "### 🔦 Lighthouse Audit Results" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| URL | Performance | Accessibility | Best Practices | SEO |" >> $GITHUB_STEP_SUMMARY + echo "|-----|-------------|---------------|----------------|-----|" >> $GITHUB_STEP_SUMMARY + echo '${{ steps.audit.outputs.manifest }}' | jq -r '.[] | "| \(.url) | \(.summary.performance * 100 | round)% | \(.summary.accessibility * 100 | round)% | \(.summary["best-practices"] * 100 | round)% | \(.summary.seo * 100 | round)% |"' >> $GITHUB_STEP_SUMMARY || true + echo "" >> $GITHUB_STEP_SUMMARY + echo "Full reports: ${{ steps.audit.outputs.links }}" >> $GITHUB_STEP_SUMMARY + continue-on-error: true