Test/GitHub actions #25
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lighthouse | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
lighthouse-ci: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Capture Vercel Preview | |
uses: patrickedqvist/[email protected] | |
id: vercel_preview_url | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
max_timeout: 300 | |
- name: Audit Preview URL with Lighthouse | |
uses: treosh/lighthouse-ci-action@v11 | |
with: | |
configPath: './.lighthouserc.json' | |
urls: | |
${{ steps.vercel_preview_url.outputs.url }}/ | |
${{ steps.vercel_preview_url.outputs.url }}/blog | |
${{ steps.vercel_preview_url.outputs.url }}/projects | |
${{ steps.vercel_preview_url.outputs.url }}/about | |
uploadArtifacts: true # save results as a action artifacts | |
temporaryPublicStorage: true # upload lighthouse report to the temporary storage | |
- name: Format Lighthouse Score | |
# Transform the audit results into a single, friendlier output | |
id: format_lighthouse_score | |
uses: actions/github-script@v7 | |
env: | |
# using env as input to our script | |
# see https://github.com/actions/github-script#use-env-as-input | |
LIGHTHOUSE_RESULT: ${{ steps.lighthouse_audit.outputs.manifest }} | |
LIGHTHOUSE_LINKS: ${{ steps.lighthouse_audit.outputs.links }} | |
VERCEL_PREVIEW_URL: ${{ steps.vercel_preview_url.outputs.url }} | |
with: | |
# Run as a separate file so we do not have to inline all of our formatting logic. | |
# See https://github.com/actions/github-script#run-a-separate-file for more info. | |
script: | | |
const { formatLighthouseResults } = await import('${{github.workspace}}/src/scripts/lighthouse/index.ts') | |
await formatLighthouseResults({core}) | |
- name: Add Comment to PR | |
# Replace the previous message with our formatted lighthouse results | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
# Reference the previously created comment | |
comment_tag: 'lighthouse_audit' | |
message: | | |
${{ steps.format_lighthouse_score.outputs.comment }} |