-
Notifications
You must be signed in to change notification settings - Fork 200
Fix lighthouse_comment workflow to handle workflow_run event context #315
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
base: main
Are you sure you want to change the base?
Changes from all commits
180e95b
9337f20
2289cc1
cc84881
a510977
4a4ef7d
5202ddf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,20 +13,36 @@ permissions: | |||||
| jobs: | ||||||
| comment: | ||||||
| runs-on: ubuntu-latest | ||||||
| if: github.event.workflow_run.conclusion == 'success' | ||||||
|
|
||||||
| steps: | ||||||
| # Download artifacts from the completed "Lighthouse – Run" workflow | ||||||
| # The run-id parameter is critical - it specifies to download from the | ||||||
| # triggering workflow run, not the current workflow (which has no artifacts) | ||||||
| # Note: github-token is not needed as the default GITHUB_TOKEN has sufficient | ||||||
| # permissions to download artifacts from the same repository | ||||||
| - name: Download Lighthouse comment artifact | ||||||
| uses: actions/download-artifact@v4 | ||||||
| with: | ||||||
| name: lighthouse-comment | ||||||
| path: . | ||||||
| run-id: ${{ github.event.workflow_run.id }} | ||||||
|
|
||||||
| - name: Ensure comment file exists | ||||||
| run: test -f lighthouse-comment.md | ||||||
|
|
||||||
| - name: Extract PR number | ||||||
| id: pr | ||||||
| run: | | ||||||
| PR_NUMBER=$(jq -r '.workflow_run.pull_requests[0].number' <<< '${{ toJSON(github.event) }}') | ||||||
| if [ -z "$PR_NUMBER" ] || [ "$PR_NUMBER" = "null" ]; then | ||||||
| echo "❌ Error: Could not extract PR number from workflow run event" | ||||||
|
||||||
| echo "❌ Error: Could not extract PR number from workflow run event" | |
| echo "❌ Error: Could not extract a PR number from the workflow_run event. This usually means the triggering workflow run was not associated with a pull request or workflow_run.pull_requests was empty. Next, check that the upstream \"Lighthouse – Run\" workflow was triggered by a pull_request-related event and confirm the repository/workflow settings allow PR context to be included in workflow_run payloads." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actions/download-artifact@v4withrun-idcalls the Actions Artifacts API; with the workflow-levelpermissions:block present, the defaultGITHUB_TOKENno longer has implicitactions: read. This will typically fail withResource not accessible by integration. Addactions: read(or remove the explicit permissions block and set least-privilege explicitly includingactions: read) so the artifact download can succeed.