()
| 1807 | // both `pull_request` and `pull_request_target` (under `pull_request_target`, |
| 1808 | // GITHUB_REF points at the base branch, not refs/pull/N/merge). |
| 1809 | const eventName = process.env.GITHUB_EVENT_NAME; |
| 1810 | if (eventName === 'pull_request' || eventName === 'pull_request_target') { |
| 1811 | const event = readGitHubEventPayload(); |
| 1812 | const num = event?.pull_request?.number; |
| 1813 | if (typeof num === 'number') return String(num); |
| 1814 | // Fallback for `pull_request`: parse GITHUB_REF if payload wasn't readable. |
| 1815 | if (eventName === 'pull_request') { |
| 1816 | const match = process.env.GITHUB_REF?.match(/refs\/pull\/(\d+)\//); |
| 1817 | if (match) return match[1]!; |
| 1818 | } |
| 1819 | } |
| 1820 | // Also check for explicit env var — validate it's numeric |
no outgoing calls
no test coverage detected
searching dependent graphs…