@@ -15,12 +15,15 @@ checkInputs().then(() => {
15
15
async function checkInputs ( ) {
16
16
const eventPath = process . env . GITHUB_EVENT_PATH ,
17
17
event = eventPath && require ( eventPath ) ,
18
+ token = process . env . GITHUB_TOKEN ,
18
19
isPR = process . env . GITHUB_EVENT_NAME ?. includes ( 'pull_request' ) ,
19
20
sha = ( event ?. pull_request ?. head ?. sha || process . env . GITHUB_SHA ) as string ,
20
21
defaultRef = isPR
21
22
? event ?. pull_request ?. head ?. ref as string
22
23
: process . env . GITHUB_REF ?. substring ( 11 )
23
24
25
+ if ( ! token ) warning ( 'The GITHUB_TOKEN env variable is missing: the action may not work as expected.' )
26
+
24
27
const actualRef = setDefault ( 'ref' , defaultRef || '' )
25
28
26
29
let author = event ?. head_commit ?. author
@@ -29,8 +32,8 @@ async function checkInputs() {
29
32
30
33
// https://docs.github.com/en/rest/reference/repos#get-a-commit--code-samples
31
34
const url = `https://api.github.com/repos/${ process . env . GITHUB_REPOSITORY } /commits/${ sha } ` ,
32
- headers = process . env . GITHUB_TOKEN ? {
33
- Authorization : `Bearer ${ process . env . GITHUB_TOKEN } `
35
+ headers = token ? {
36
+ Authorization : `Bearer ${ token } `
34
37
} : undefined ,
35
38
commit = ( await axios . get ( url , { headers } ) . catch ( err => {
36
39
info ( '::group::Request error:' )
0 commit comments