Skip to content

Commit c227f03

Browse files
committed
add event type
1 parent 509ab62 commit c227f03

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

app.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Octokit} from "@octokit/core";
22
import express, {NextFunction, Request, Response} from "express";
33
import {Webhook, WebhookUnbrandedRequiredHeaders, WebhookVerificationError} from "standardwebhooks"
4-
import {RenderDeploy, RenderService, WebhookPayload} from "./render";
4+
import {RenderDeploy, RenderEvent, RenderService, WebhookPayload} from "./render";
55

66
const app = express();
77
const port = process.env.PORT || 3001;
@@ -70,13 +70,13 @@ async function handleWebhook(payload: WebhookPayload) {
7070
return
7171
}
7272

73-
const deploy: RenderDeploy = await fetchDeployInfo(payload.data.serviceId, event.details.deployId)
73+
const deploy = await fetchDeployInfo(payload.data.serviceId, event.details.deployId)
7474
if (!deploy.commit) {
7575
console.log(`ignoring deploy success for image backed service: ${payload.data.serviceId}`)
7676
return
7777
}
7878

79-
const service: RenderService = await fetchServiceInfo(payload)
79+
const service = await fetchServiceInfo(payload)
8080

8181
if (! service.repo.includes(`${githubOwnerName}/${githubRepoName}`)) {
8282
console.log(`ignoring deploy success for another service: ${service.name}`)
@@ -112,7 +112,7 @@ async function triggerWorkflow(serviceName: string, branch: string) {
112112
// fetchEventInfo fetches the event that triggered the webhook
113113
// some events have additional information that isn't in the webhook payload
114114
// for example, deploy events have the deploy id
115-
async function fetchEventInfo(payload: WebhookPayload) {
115+
async function fetchEventInfo(payload: WebhookPayload): Promise<RenderEvent> {
116116
const res = await fetch(
117117
`${renderAPIURL}/events/${payload.data.id}`,
118118
{
@@ -131,7 +131,7 @@ async function fetchEventInfo(payload: WebhookPayload) {
131131
}
132132
}
133133

134-
async function fetchDeployInfo(serviceId: string, deployId: string) {
134+
async function fetchDeployInfo(serviceId: string, deployId: string): Promise<RenderDeploy> {
135135
const res = await fetch(
136136
`${renderAPIURL}/services/${serviceId}/deploys/${deployId}`,
137137
{
@@ -150,7 +150,7 @@ async function fetchDeployInfo(serviceId: string, deployId: string) {
150150
}
151151
}
152152

153-
async function fetchServiceInfo(payload: WebhookPayload) {
153+
async function fetchServiceInfo(payload: WebhookPayload): Promise<RenderService> {
154154
const res = await fetch(
155155
`${renderAPIURL}/services/${payload.data.serviceId}`,
156156
{

render.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ export interface RenderDeploy {
2525
id: string
2626
commit?: Commit
2727
}
28+
29+
export interface RenderEvent {
30+
id: string
31+
type: string
32+
details: any
33+
}

0 commit comments

Comments
 (0)