1+ import { detectCiPullRequestContext } from './detect-ci-pull-request-context.mts'
12import { getDefaultOrgSlug } from './fetch-default-org-slug.mts'
23import constants from '../../constants.mts'
34import { debugDir , debugFn } from '../../utils/debug.mts'
4- import { envAsString } from '../../utils/env.mts'
55import {
66 detectDefaultBranch ,
77 getRepoName ,
@@ -18,10 +18,7 @@ import { handleCreateNewScan } from '../scan/handle-create-new-scan.mts'
1818 * `pull_request` for falsy values).
1919 */
2020export function detectCiPullRequestNumber ( ) : number {
21- const match = / ^ r e f s \/ p u l l \/ ( \d + ) \/ / . exec (
22- envAsString ( process . env [ 'GITHUB_REF' ] ) ,
23- )
24- return match ? Number ( match [ 1 ] ) : 0
21+ return detectCiPullRequestContext ( ) . number
2522}
2623
2724export async function handleCi ( autoManifest : boolean ) : Promise < void > {
@@ -39,6 +36,7 @@ export async function handleCi(autoManifest: boolean): Promise<void> {
3936 }
4037
4138 const orgSlug = orgSlugCResult . data
39+ const { number : pullRequest } = detectCiPullRequestContext ( )
4240 const cwd = process . cwd ( )
4341 const branchName = ( await gitBranch ( cwd ) ) || ( await detectDefaultBranch ( cwd ) )
4442 const repoName = await getRepoName ( cwd )
@@ -62,7 +60,7 @@ export async function handleCi(autoManifest: boolean): Promise<void> {
6260 outputKind : 'json' ,
6361 // When 'pendingHead' is true, it requires 'branchName' set and 'tmp' false.
6462 pendingHead : true ,
65- pullRequest : detectCiPullRequestNumber ( ) ,
63+ pullRequest,
6664 reach : {
6765 dynamicSbomInference : undefined ,
6866 excludePaths : [ ] ,
0 commit comments