11import { db , NotFoundError } from "../db/index.ts" ;
2- import { DeploymentRepo } from "../db/repo/deployment.ts" ;
32import type { components } from "../generated/openapi.ts" ;
43import { type LogStream , type LogType } from "../generated/prisma/enums.ts" ;
54import { env } from "../lib/env.ts" ;
@@ -10,7 +9,7 @@ import {
109 UserNotFoundError ,
1110 ValidationError ,
1211} from "./common/errors.ts" ;
13- import { deploymentService } from "./helper/index.ts" ;
12+ import { deploymentConfigService , deploymentService } from "./helper/index.ts" ;
1413
1514export async function processGitHubWebhookPayload (
1615 event : string ,
@@ -150,11 +149,16 @@ async function handlePush(payload: components["schemas"]["webhook-push"]) {
150149 for ( const app of apps ) {
151150 const org = await db . org . getById ( app . orgId ) ;
152151 const oldConfig = ( await db . app . getDeploymentConfig ( app . id ) ) . asGitConfig ( ) ;
152+ const config = deploymentConfigService . populateNewCommit (
153+ oldConfig ,
154+ app ,
155+ payload . head_commit . id ,
156+ ) ;
153157 await deploymentService . create ( {
154158 org,
155159 app,
156160 commitMessage : payload . head_commit . message ,
157- config : DeploymentRepo . cloneWorkloadConfig ( oldConfig ) ,
161+ config,
158162 git : {
159163 checkRun : {
160164 pending : false ,
@@ -197,13 +201,20 @@ async function handleWorkflowRun(
197201 if ( payload . action === "requested" ) {
198202 for ( const app of apps ) {
199203 const org = await db . org . getById ( app . orgId ) ;
200- const config = ( await db . app . getDeploymentConfig ( app . id ) ) . asGitConfig ( ) ;
204+ const oldConfig = (
205+ await db . app . getDeploymentConfig ( app . id )
206+ ) . asGitConfig ( ) ;
207+ const config = deploymentConfigService . populateNewCommit (
208+ oldConfig ,
209+ app ,
210+ payload . workflow_run . head_commit . id ,
211+ ) ;
201212 await deploymentService . create ( {
202213 org,
203214 app,
204215 commitMessage : payload . workflow_run . head_commit . message ,
205216 workflowRunId : payload . workflow_run . id ,
206- config : DeploymentRepo . cloneWorkloadConfig ( config ) ,
217+ config,
207218 git : {
208219 checkRun : {
209220 pending : true ,
0 commit comments