Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor lighthouse check workflows #646

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check
name: CI

on:
pull_request:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/deployment-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deployment CI

on:
deployment_status:

jobs:
Lighthouse:
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
strategy:
fail-fast: false
matrix:
route: ["", "/projects", "/contact"]
uses: ./.github/workflows/lhci.yml
with:
url: ${{ github.event.deployment_status.environment_url }}${{ matrix.route}}
config-path: ./lighthouserc.Preview.json
secrets: inherit
37 changes: 37 additions & 0 deletions .github/workflows/lhci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
workflow_call:
inputs:
url:
required: true
type: string
description: Full URL path to check
config-path:
required: true
type: string
description: Path to lhci config file
secrets:
LHCI_GITHUB_APP_TOKEN:
required: true
VERCEL_AUTOMATION_BYPASS_SECRET:
required: true

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: false
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Audit URL using Lighthouse
run: |
pnpm add --global @lhci/cli
lhci autorun --config=${{ inputs.config-path }}
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
LHCI_COLLECT__URL: ${{ inputs.url }}
LHCI_COLLECT__SETTINGS__EXTRA_HEADERS: '{"x-vercel-protection-bypass": "${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}"}'
25 changes: 5 additions & 20 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
name: Lighthouse test

on:
deployment_status:
schedule:
- cron: "0 7 * * *"
workflow_dispatch:

jobs:
run:
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
route: ["", "/projects", "/contact"]
steps:
- uses: actions/checkout@v4
with:
lfs: false
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Audit URL using Lighthouse
run: |
pnpm add --global @lhci/cli
lhci autorun --config=./lighthouserc.${{ github.event.deployment.environment || 'Production' }}.json
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
LHCI_COLLECT__URL: ${{ github.event.deployment_status.environment_url || 'https://www.lukastrombach.dev' }}${{ matrix.route }}
LHCI_COLLECT__SETTINGS__EXTRA_HEADERS: '{"x-vercel-protection-bypass": "${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}"}'
uses: ./.github/workflows/lhci.yml
with:
url: https://www.lukastrombach.dev${{ matrix.route }}
config-path: ./lighthouserc.Production.json
secrets: inherit
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<div align=center>

[![Checks](https://github.com/Trombach/astro-homepage/actions/workflows/pr-checks.yml/badge.svg)](https://github.com/Trombach/astro-homepage/actions/workflows/pr-checks.yml)
[![CI](https://github.com/Trombach/astro-homepage/actions/workflows/ci.yml/badge.svg)](https://github.com/Trombach/astro-homepage/actions/workflows/ci.yml)
![Staging](https://img.shields.io/github/deployments/Trombach/astro-homepage/Production?logo=vercel&label=Staging)
[![Lighthouse tests](https://github.com/Trombach/astro-homepage/actions/workflows/lighthouse.yml/badge.svg?event=schedule)](https://github.com/Trombach/astro-homepage/actions/workflows/lighthouse.yml)
[![Lighthouse Scores](https://github.com/Trombach/astro-homepage/actions/workflows/lighthouse.yml/badge.svg?event=schedule)](https://github.com/Trombach/astro-homepage/actions/workflows/lighthouse.yml)

</div>

Expand Down
Loading