@@ -19,12 +19,23 @@ jobs:
1919 name: Run Lighthouse Insights
2020 runs-on: ubuntu-latest
2121 steps:
22- - uses: actions/checkout@v5
22+ - name: Checkout (PR)
23+ if: github.event_name == 'pull_request'
24+ uses: actions/checkout@v5
2325 with:
2426 token: ${{ secrets.GITHUB_TOKEN }}
2527 ref: ${{ github.event.pull_request.head.ref }}
2628 repository: ${{ github.event.pull_request.head.repo.full_name }}
2729
30+ # repository_dispatch context from Vercel
31+ - name: Checkout (repository_dispatch)
32+ if: github.event_name == 'repository_dispatch'
33+ uses: actions/checkout@v5
34+ with:
35+ token: ${{ secrets.GITHUB_TOKEN }}
36+ ref: ${{ github.event.client_payload.git.sha }}
37+ repository: ${{ github.repository }}
38+
2839 - uses: actions/setup-node@v6
2940 with:
3041 node-version-file: ".nvmrc"
@@ -42,20 +53,18 @@ jobs:
4253 configPath: ./.lighthouserc.json
4354 urls: |
4455 ${{ inputs.url }}
45-
56+
4657 - name: Create lighthouse report
4758 id: lighthouse-results-generate
4859 env:
4960 GITHUB_EVENT_NAME: ${{ github.event_name }}
50- run: |
51- python scripts/generate-lighthouse-report.py
61+ run: python scripts/generate-lighthouse-report.py
5262
5363 - name: Comment on PR with Lighthouse insights
54- uses: mshick/add-pr-comment@v2
5564 if: github.event_name == 'pull_request'
65+ uses: mshick/add-pr-comment@v2
5666 with:
57- message: |
58- ${{ steps.lighthouse-results-generate.outputs.report }}
67+ message: ${{ steps.lighthouse-results-generate.outputs.report }}
5968 repo-token: ${{ secrets.GITHUB_TOKEN }}
6069 allow-repeats: true
6170
6675 "$report_content" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
6776
6877 - name: Create token for GitHub App
69- uses: actions/create-github-app-token@v2
7078 if: github.event_name != 'pull_request'
79+ uses: actions/create-github-app-token@v2
7180 id: get-app-token
7281 with:
7382 app-id: ${{ vars.GH_APP_ID }}
8291 uses: dsanders11/github-app-commit-action@v1
8392 with:
8493 message: "Updated Lighthouse markdown report generated by workflow run: ${{ github.run_number }} [skip ci]"
85- force: true # to make sure the update is a fast-forward update
86- token: ${{ steps.get-app-token.outputs.token }}
94+ force: true
95+ token: ${{ steps.get-app-token.outputs.token }}
0 commit comments