11import { Probot } from "probot" ;
2+ import { EmitterWebhookEvent } from "@octokit/webhooks" ;
3+
4+ interface InstallationLite {
5+ id : number ;
6+ node_id : string ;
7+ }
8+ interface GitHubAppWebHookPayload {
9+ installation : InstallationLite ;
10+ repository : {
11+ name : string ;
12+ owner : {
13+ login : string ;
14+ }
15+ }
16+ }
17+
218// import * as fs from 'fs';
319// import * as yaml from 'yaml';
420
@@ -13,24 +29,26 @@ import { Probot } from "probot";
1329// }
1430
1531const setupApp = ( app : Probot ) => {
16- app . onAny ( async ( context : any ) => {
17- const octokit = await app . auth ( context . payload . installation . id ) ;
32+ app . onAny ( async ( event : EmitterWebhookEvent ) => {
33+ const payload = event . payload as GitHubAppWebHookPayload ;
34+
35+ const octokit = await app . auth ( payload . installation . id ) ;
1836
1937 // if (filter(context)) {
2038 await octokit . repos . createDispatchEvent ( {
21- owner : context . payload . repository . owner . login ,
22- repo : context . payload . repository . name ,
23- event_type : context . name ,
24- client_payload : context . payload ,
39+ owner : payload . repository . owner . login ,
40+ repo : payload . repository . name ,
41+ event_type : event . name ,
42+ client_payload : payload as unknown as { [ key : string ] : unknown } ,
2543 } ) ;
2644 // }
2745 } ) ;
2846} ;
2947
30- // const filter = (context: any ): boolean => {
48+ // const filter = (event: EmitterWebhookEvent ): boolean => {
3149// if (filter_config === undefined) return true;
3250
33- // const event_name = context .name;
51+ // const event_name = event .name;
3452
3553// // check if the event type is allowed by the filter config
3654// // if there is an include list, and this type isn't on it, return false
@@ -41,7 +59,7 @@ const setupApp = (app: Probot) => {
4159
4260// // check the event payload against the filter config's include rule, if it exists
4361// const include_filter = filter_config.include[event_name];
44- // const payload = context .payload;
62+ // const payload = event .payload;
4563
4664// if (include_filter !== undefined) {
4765
0 commit comments