Skip to content

Commit

Permalink
Create lighthouse.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanPabloDiaz authored Jul 4, 2024
1 parent 0235841 commit bb345d1
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Lighthouse CI

on:
workflow_dispatch:
pull_request:
branches:
- "main"

jobs:
lighthouse:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Audit URLs using Lighthouse
id: lighthouse
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
https://freecodecamp.jpdiaz.dev/
budgetPath: ./budget.json # test performance budgets
uploadArtifacts: true # save results as an action artifacts
temporaryPublicStorage: true # upload lighthouse report to the temporary storage

- name: Add comment with Lighthouse action URL
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const runId = context.runId;
const owner = context.repo.owner;
const repo = context.repo.repo;
const actionUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`;
const commentBody = `
**Check the Lighthouse CI Report** 🚀
1. **Audit URL**:\`https://freecodecamp.jpdiaz.dev/\`
2. **Open the [Lighthouse CI action here](${actionUrl})**
3. **Check the Report**:
- Click on \`lighthouse\` > \`Audit URLs using Lighthouse\` > \`Uploading\` > \`open the report\` to see the full report.
`;
github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: context.issue.number,
body: commentBody
});

0 comments on commit bb345d1

Please sign in to comment.