From a2b4d400afdf2d7d77d9d76313739456537c7916 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 10 Oct 2022 15:28:16 +0200 Subject: [PATCH] fix: add git sha to build args --- apps/api/src/lib/buildPacks/common.ts | 8 +++++--- apps/api/src/lib/importers/github.ts | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/api/src/lib/buildPacks/common.ts b/apps/api/src/lib/buildPacks/common.ts index f2d76c249..fd36a2ea6 100644 --- a/apps/api/src/lib/buildPacks/common.ts +++ b/apps/api/src/lib/buildPacks/common.ts @@ -580,7 +580,8 @@ export async function buildImage({ dockerId, isCache = false, debug = false, - dockerFileLocation = '/Dockerfile' + dockerFileLocation = '/Dockerfile', + commit }) { if (isCache) { await saveBuildLog({ line: `Building cache image started.`, buildId, applicationId }); @@ -596,8 +597,9 @@ export async function buildImage({ } const dockerFile = isCache ? `${dockerFileLocation}-cache` : `${dockerFileLocation}` const cache = `${applicationId}:${tag}${isCache ? '-cache' : ''}` - const { git_sha } = await asyncExecShell(`git rev-parse HEAD`) - await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker build --progress plain -f ${workdir}/${dockerFile} -t ${cache} --build-arg SOURCE_COMMIT=${git_sha} ${workdir}` }) + + await executeDockerCmd({ debug, buildId, applicationId, dockerId, command: `docker build --progress plain -f ${workdir}/${dockerFile} -t ${cache} --build-arg SOURCE_COMMIT=${commit} ${workdir}` }) + const { status } = await prisma.build.findUnique({ where: { id: buildId } }) if (status === 'canceled') { throw new Error('Deployment canceled.') diff --git a/apps/api/src/lib/importers/github.ts b/apps/api/src/lib/importers/github.ts index 798931d7a..f42461939 100644 --- a/apps/api/src/lib/importers/github.ts +++ b/apps/api/src/lib/importers/github.ts @@ -73,6 +73,4 @@ export default async function ({ const { stdout: commit } = await asyncExecShell(`cd ${workdir}/ && git rev-parse HEAD`); return commit.replace('\n', ''); - - }