gnodet opened a new pull request, #331:
URL: https://github.com/apache/maven-gh-actions-shared/pull/331

   ## Problem
   
   The YAML `if:` condition on the `license-declaration` job does not work 
inside a reusable workflow called via `workflow_call`:
   
   > `github.event.pull_request` is **undefined** inside a reusable workflow
   
   This is confirmed by the debug log:
   ```
   TypeError: Cannot read properties of undefined (reading 'pull_request')
   ```
   
   So the skip condition (OWNER/MEMBER/COLLABORATOR) never fired, and the check 
ran for every PR — including those opened by Apache committers whose org 
membership is private (they appear as `COLLABORATOR`, not `MEMBER`).
   
   ## Fix
   
   Move the skip logic **into the github-script step** itself, where the GitHub 
API is available:
   
   ```js
   const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: 
prNumber });
   const skipAssociations = ['OWNER', 'MEMBER', 'COLLABORATOR'];
   if (pr.user?.type === 'Bot' || 
skipAssociations.includes(pr.author_association)) {
     core.info(`Skipping license check: ...`);
     return;
   }
   ```
   
   This approach:
   - Uses the live API (not the stale event payload)
   - Works correctly inside reusable workflows
   - Covers all three cases: OWNER, MEMBER, and **COLLABORATOR** (private org 
members = most Apache committers)
   
   Also moves the `pr.get()` call before the regex check since the data is now 
needed earlier.
   
   The broken YAML `if:` condition and the temporary debug step are removed.
   
   ## Related
   
   - apache/maven#13334 — blocked by this bug (committer PR failing the license 
check)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to