@@ -7,6 +7,7 @@ export const BOUNTY_LABELS = ['All For One', 'The Bug Slayer'] as const
77export type BountyType = typeof BOUNTY_LABELS [ number ]
88type CommentMap = { [ K in BountyType ] : string }
99export type Issue = { title : string , body : string , labels : string [ ] , bountyType : BountyType }
10+ type GitHubIssue = { [ key : string ] : any , number : number , html_url ?: string | undefined , body ?: string | undefined }
1011
1112const COMMENT_TASK_LIST_AFO = `## Task List
1213- [ ] CodeQL Initial assessment - In case of rejection, please record your decision in the comment below:
@@ -55,8 +56,23 @@ const COMMENT_SCORING = `## Scoring
5556
5657const COMMENT_FIRST_SUBMISSION = `## :tada: First submission for this user :tada:`
5758
58- export const generateInternalIssueContentFromPayload = async ( payload : WebhookPayload ) : Promise < Issue | undefined > => {
59- const issue = payload . issue
59+ const getIssueFromRef = async ( issueRef : string | undefined ) : Promise < GitHubIssue | undefined > => {
60+ if ( ! issueRef )
61+ return undefined
62+ const token : string | undefined = process . env [ 'GITHUB_TOKEN' ]
63+ if ( token === undefined )
64+ return undefined
65+ const octokit : github . GitHub = new github . GitHub ( token )
66+ const issueResponse = await octokit . issues . get ( {
67+ owner : github . context . repo . owner ,
68+ repo : github . context . repo . repo ,
69+ issue_number : Number ( issueRef ) ,
70+ } ) ;
71+ return issueResponse . data
72+ }
73+
74+ export const generateInternalIssueContentFromPayload = async ( payload ?: WebhookPayload , issueRef ?: string ) : Promise < Issue | undefined > => {
75+ const issue = await getIssueFromRef ( issueRef ) || payload ?. issue
6076 let result : Issue = { title : 'none' , body : 'none' , labels : [ ] , bountyType : 'All For One' }
6177 let bountyIssue : boolean = false
6278 let bountyType = ''
@@ -202,7 +218,7 @@ export const isFirstSubmission = async (payload: WebhookPayload, token : string
202218}
203219
204220const run = async ( ) : Promise < void > => {
205- const internalIssue = await generateInternalIssueContentFromPayload ( github . context . payload )
221+ const internalIssue = await generateInternalIssueContentFromPayload ( github . context . payload , core . getInput ( 'specific_issue' ) )
206222 if ( ! internalIssue )
207223 return
208224
0 commit comments