@@ -46,6 +46,8 @@ const INVALID_REVIEW_COMMENT = (commentUrl) =>
46
46
47
47
// Retrieve octokit instance.
48
48
const OCTOKIT = github . getOctokit ( getGithubToken ( ) ) ;
49
+ const PULL_REQUEST_ID = prNumber ? prNumber : getPrNumber ( ) ;
50
+ const { OWNER , REPO } = getRepoInfo ( github . context ) ;
49
51
50
52
/**
51
53
* Retrieve PR number from the event payload.
@@ -315,29 +317,27 @@ export const run = async (prNumber) => {
315
317
\r${ THEME_CONTRIB_GUIDELINESS }
316
318
` ;
317
319
const ccc = new ColorContrastChecker ( ) ;
318
- const pullRequestId = prNumber ? prNumber : getPrNumber ( ) ;
319
320
const commenter = getCommenter ( ) ;
320
- const { owner, repo } = getRepoInfo ( github . context ) ;
321
- debug ( `Owner: ${ owner } ` ) ;
322
- debug ( `Repo: ${ repo } ` ) ;
321
+ debug ( `Owner: ${ OWNER } ` ) ;
322
+ debug ( `Repo: ${ REPO } ` ) ;
323
323
debug ( `Commenter: ${ commenter } ` ) ;
324
324
325
325
// Retrieve the PR diff and preview-theme comment.
326
326
debug ( "Retrieve PR diff..." ) ;
327
327
const res = await OCTOKIT . pulls . get ( {
328
- owner ,
329
- repo ,
330
- pull_number : pullRequestId ,
328
+ OWNER ,
329
+ REPO ,
330
+ pull_number : PULL_REQUEST_ID ,
331
331
mediaType : {
332
332
format : "diff" ,
333
333
} ,
334
334
} ) ;
335
335
debug ( "Retrieve preview-theme comment..." ) ;
336
336
const comment = await findComment (
337
337
OCTOKIT ,
338
- pullRequestId ,
339
- owner ,
340
- repo ,
338
+ PULL_REQUEST_ID ,
339
+ OWNER ,
340
+ REPO ,
341
341
commenter ,
342
342
) ;
343
343
@@ -519,9 +519,9 @@ export const run = async (prNumber) => {
519
519
if ( ! DRY_RUN ) {
520
520
comment_url = await upsertComment ( OCTOKIT , {
521
521
comment_id : comment ?. id ,
522
- issue_number : pullRequestId ,
523
- owner ,
524
- repo ,
522
+ issue_number : PULL_REQUEST_ID ,
523
+ OWNER ,
524
+ REPO ,
525
525
body : commentBody ,
526
526
} ) ;
527
527
} else {
@@ -541,17 +541,17 @@ export const run = async (prNumber) => {
541
541
if ( ! DRY_RUN ) {
542
542
await addReview (
543
543
OCTOKIT ,
544
- pullRequestId ,
545
- owner ,
546
- repo ,
544
+ PULL_REQUEST_ID ,
545
+ OWNER ,
546
+ REPO ,
547
547
reviewState ,
548
548
reviewReason ,
549
549
) ;
550
550
await addRemoveLabel (
551
551
OCTOKIT ,
552
- pullRequestId ,
553
- owner ,
554
- repo ,
552
+ PULL_REQUEST_ID ,
553
+ OWNER ,
554
+ REPO ,
555
555
"invalid" ,
556
556
! themesValid ,
557
557
) ;
@@ -564,17 +564,17 @@ export const run = async (prNumber) => {
564
564
if ( ! DRY_RUN ) {
565
565
await addReview (
566
566
OCTOKIT ,
567
- pullRequestId ,
568
- owner ,
569
- repo ,
567
+ PULL_REQUEST_ID ,
568
+ OWNER ,
569
+ REPO ,
570
570
"REQUEST_CHANGES" ,
571
571
error . message ,
572
572
) ;
573
573
await addRemoveLabel (
574
574
OCTOKIT ,
575
- pullRequestId ,
576
- owner ,
577
- repo ,
575
+ PULL_REQUEST_ID ,
576
+ OWNER ,
577
+ REPO ,
578
578
"invalid" ,
579
579
true ,
580
580
) ;
0 commit comments