2021-04-15 20:40:44 +00:00
|
|
|
const packs = require('../../../buildPacks')
|
2021-03-24 21:11:14 +00:00
|
|
|
const { saveAppLog } = require('../../logging')
|
|
|
|
|
const Deployment = require('../../../models/Deployment')
|
|
|
|
|
|
|
|
|
|
module.exports = async function (configuration) {
|
|
|
|
|
const { id, organization, name, branch } = configuration.repository
|
|
|
|
|
const { domain } = configuration.publish
|
|
|
|
|
const deployId = configuration.general.deployId
|
|
|
|
|
|
|
|
|
|
const execute = packs[configuration.build.pack]
|
|
|
|
|
if (execute) {
|
2021-04-19 07:46:05 +00:00
|
|
|
await Deployment.findOneAndUpdate(
|
|
|
|
|
{ repoId: id, branch, deployId, organization, name, domain },
|
|
|
|
|
{ repoId: id, branch, deployId, organization, name, domain, progress: 'inprogress' })
|
|
|
|
|
await saveAppLog('### Building application.', configuration)
|
|
|
|
|
await execute(configuration)
|
|
|
|
|
await saveAppLog('### Building done.', configuration)
|
2021-03-24 21:11:14 +00:00
|
|
|
} else {
|
2021-04-15 20:40:44 +00:00
|
|
|
try {
|
|
|
|
|
await Deployment.findOneAndUpdate(
|
|
|
|
|
{ repoId: id, branch, deployId, organization, name, domain },
|
|
|
|
|
{ repoId: id, branch, deployId, organization, name, domain, progress: 'failed' })
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// Hmm.
|
|
|
|
|
}
|
2021-04-19 07:46:05 +00:00
|
|
|
throw new Error('No buildpack found.')
|
2021-03-24 21:11:14 +00:00
|
|
|
}
|
|
|
|
|
}
|