Lighthouse CI #1
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 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://jpshop.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://jpshop.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 | |
}); |