@@ -28,8 +28,9 @@ let _octokit: Octokit | undefined
2828function getOctokit ( ) {
2929 if ( _octokit === undefined ) {
3030 _octokit = new Octokit ( {
31- // Lazily access constants.ENV.SOCKET_SECURITY_GITHUB_PAT.
32- auth : constants . ENV . SOCKET_SECURITY_GITHUB_PAT
31+ // Lazily access constants.ENV properties.
32+ auth :
33+ constants . ENV . SOCKET_SECURITY_GITHUB_PAT || constants . ENV . GITHUB_TOKEN
3334 } )
3435 }
3536 return _octokit
@@ -40,8 +41,8 @@ export function getOctokitGraphql() {
4041 if ( ! _octokitGraphql ) {
4142 _octokitGraphql = OctokitGraphql . defaults ( {
4243 headers : {
43- // Lazily access constants.ENV.SOCKET_SECURITY_GITHUB_PAT .
44- authorization : `token ${ constants . ENV . SOCKET_SECURITY_GITHUB_PAT } `
44+ // Lazily access constants.ENV properties .
45+ authorization : `token ${ constants . ENV . SOCKET_SECURITY_GITHUB_PAT || constants . ENV . GITHUB_TOKEN } `
4546 }
4647 } )
4748 }
@@ -364,12 +365,10 @@ export async function openPr(
364365 } as OpenPrOptions
365366 // Lazily access constants.ENV.GITHUB_ACTIONS.
366367 if ( constants . ENV . GITHUB_ACTIONS ) {
367- // Lazily access constants.ENV.SOCKET_SECURITY_GITHUB_PAT.
368- const pat = constants . ENV . SOCKET_SECURITY_GITHUB_PAT
369- if ( ! pat ) {
370- throw new Error ( 'Missing SOCKET_SECURITY_GITHUB_PAT environment variable' )
371- }
372- const url = `https://x-access-token:${ pat } @github.com/${ owner } /${ repo } `
368+ // Lazily access constants.ENV properties.
369+ const token =
370+ constants . ENV . SOCKET_SECURITY_GITHUB_PAT || constants . ENV . GITHUB_TOKEN
371+ const url = `https://x-access-token:${ token } @github.com/${ owner } /${ repo } `
373372 await spawn ( 'git' , [ 'remote' , 'set-url' , 'origin' , url ] , {
374373 cwd
375374 } )
0 commit comments