1
1
import { Octokit } from "@octokit/core" ;
2
2
import express , { NextFunction , Request , Response } from "express" ;
3
3
import { Webhook , WebhookUnbrandedRequiredHeaders , WebhookVerificationError } from "standardwebhooks"
4
- import { RenderDeploy , RenderService , WebhookPayload } from "./render" ;
4
+ import { RenderDeploy , RenderEvent , RenderService , WebhookPayload } from "./render" ;
5
5
6
6
const app = express ( ) ;
7
7
const port = process . env . PORT || 3001 ;
@@ -70,13 +70,13 @@ async function handleWebhook(payload: WebhookPayload) {
70
70
return
71
71
}
72
72
73
- const deploy : RenderDeploy = await fetchDeployInfo ( payload . data . serviceId , event . details . deployId )
73
+ const deploy = await fetchDeployInfo ( payload . data . serviceId , event . details . deployId )
74
74
if ( ! deploy . commit ) {
75
75
console . log ( `ignoring deploy success for image backed service: ${ payload . data . serviceId } ` )
76
76
return
77
77
}
78
78
79
- const service : RenderService = await fetchServiceInfo ( payload )
79
+ const service = await fetchServiceInfo ( payload )
80
80
81
81
if ( ! service . repo . includes ( `${ githubOwnerName } /${ githubRepoName } ` ) ) {
82
82
console . log ( `ignoring deploy success for another service: ${ service . name } ` )
@@ -112,7 +112,7 @@ async function triggerWorkflow(serviceName: string, branch: string) {
112
112
// fetchEventInfo fetches the event that triggered the webhook
113
113
// some events have additional information that isn't in the webhook payload
114
114
// for example, deploy events have the deploy id
115
- async function fetchEventInfo ( payload : WebhookPayload ) {
115
+ async function fetchEventInfo ( payload : WebhookPayload ) : Promise < RenderEvent > {
116
116
const res = await fetch (
117
117
`${ renderAPIURL } /events/${ payload . data . id } ` ,
118
118
{
@@ -131,7 +131,7 @@ async function fetchEventInfo(payload: WebhookPayload) {
131
131
}
132
132
}
133
133
134
- async function fetchDeployInfo ( serviceId : string , deployId : string ) {
134
+ async function fetchDeployInfo ( serviceId : string , deployId : string ) : Promise < RenderDeploy > {
135
135
const res = await fetch (
136
136
`${ renderAPIURL } /services/${ serviceId } /deploys/${ deployId } ` ,
137
137
{
@@ -150,7 +150,7 @@ async function fetchDeployInfo(serviceId: string, deployId: string) {
150
150
}
151
151
}
152
152
153
- async function fetchServiceInfo ( payload : WebhookPayload ) {
153
+ async function fetchServiceInfo ( payload : WebhookPayload ) : Promise < RenderService > {
154
154
const res = await fetch (
155
155
`${ renderAPIURL } /services/${ payload . data . serviceId } ` ,
156
156
{
0 commit comments