fix
This commit is contained in:
@@ -15,34 +15,27 @@ export const deploy = async ({ host, commitHash }: DeployInstance) => {
|
|||||||
const deploymentId = new Date().toISOString();
|
const deploymentId = new Date().toISOString();
|
||||||
|
|
||||||
const serviceDir = path.join(config.directory, host);
|
const serviceDir = path.join(config.directory, host);
|
||||||
|
await $`mkdir -p ${serviceDir}`;
|
||||||
|
|
||||||
// Fetch
|
// Fetch
|
||||||
await $`
|
$.cwd(serviceDir);
|
||||||
cd ${serviceDir}
|
const url = `http://deployer:${config.token}@${config.giteaUrl}/${user}/${repo}`;
|
||||||
mkdir -p src
|
await $`mkdir -p src`;
|
||||||
mkdir -p logs
|
await $`mkdir -p logs`;
|
||||||
git clone \
|
await $`git clone -b ${branch} ${url} ./src`.nothrow();
|
||||||
-b ${branch} \
|
|
||||||
http://deployer:${config.token}@${config.giteaUrl}/${user}/${repo} \
|
$.cwd(path.join(serviceDir, "src"));
|
||||||
${serviceDir}/src
|
await $`git fetch origin ${branch}`;
|
||||||
cd src
|
await $`git reset --hard origin/${branch}`;
|
||||||
git fetch origin ${branch}
|
await $`git checkout ${commitHash}`;
|
||||||
git reset --hard origin/${branch}
|
|
||||||
git checkout ${commitHash}
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Build
|
// Build
|
||||||
await $`
|
await $`make build`;
|
||||||
cd ${serviceDir}/src
|
|
||||||
make build
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Register service
|
// Register service
|
||||||
const systemdServiceName = `deployer-${host}.service`;
|
const systemdServiceName = `deployer2-${host}.service`;
|
||||||
await $`
|
await $`cat service.template | envsubst > ${serviceDir}/${systemdServiceName}`.env(
|
||||||
cat template.service | envsubst > ${serviceDir}/${systemdServiceName}
|
{
|
||||||
ln -sf ${serviceDir}/${systemdServiceName} ${config.systemServicesDir}/${systemdServiceName}
|
|
||||||
`.env({
|
|
||||||
host,
|
host,
|
||||||
port: port.toString(),
|
port: port.toString(),
|
||||||
repo,
|
repo,
|
||||||
@@ -51,11 +44,11 @@ export const deploy = async ({ host, commitHash }: DeployInstance) => {
|
|||||||
deploymentId,
|
deploymentId,
|
||||||
logsDir: path.join(serviceDir, "logs"),
|
logsDir: path.join(serviceDir, "logs"),
|
||||||
serviceDir,
|
serviceDir,
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
await $`ln -sf ${serviceDir}/${systemdServiceName} ${config.systemServicesDir}/${systemdServiceName}`;
|
||||||
|
|
||||||
// Start!
|
// Start!
|
||||||
await $`
|
await $`systemctl daemon-reload`;
|
||||||
systemctl daemon-reload
|
await $`systemctl restart ${systemdServiceName}`;
|
||||||
systemctl restart ${systemdServiceName}
|
|
||||||
`;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user