Merge pull request #1049 from matt-oakes/git-sha

Set the CAPROVER_GIT_COMMIT_SHA env var automatically when building
This commit is contained in:
Kasra Bigdeli
2021-03-13 14:34:32 -05:00
committed by GitHub
+18 -1
View File
@@ -166,12 +166,29 @@ class ServiceManager {
.getAppsDataStore()
.getAppDefinition(appName)
.then(function (app) {
const envVars = app.envVars
const includesGitCommitEnvVar = envVars.find(
(envVar) => envVar.key === 'CAPROVER_GIT_COMMIT_SHA'
)
const gitHash =
source.captainDefinitionContentSource?.gitHash ||
source.uploadedTarPathSource?.gitHash
if (gitHash && !includesGitCommitEnvVar) {
if (gitHash) {
envVars.push({
key: 'CAPROVER_GIT_COMMIT_SHA',
value: gitHash,
})
}
}
return self.imageMaker.ensureImage(
source,
appName,
app.captainDefinitionRelativeFilePath,
appVersion,
app.envVars
envVars
)
})
})