diff --git a/src/deploy.ts b/src/deploy.ts index 3ac7e68..cdf8869 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -16,6 +16,8 @@ export const deploy = async ({ host, commitHash }: DeployInstance) => { console.log(`=== ${deploymentId} ===`); console.log({ host, commitHash }); + const deployerDir = await $`pwd`.text(); + const service = config.services[host]; const { user, repo, branch, port } = indexedConfig[hash(service)]; @@ -40,19 +42,20 @@ export const deploy = async ({ host, commitHash }: DeployInstance) => { // Register service const systemdServiceName = `deployer2-${host}.service`; - await l$`cat service.template | envsubst > ${serviceDir}/${systemdServiceName}`.env( - { - host, - port: port.toString(), - repo, - branch, - commitHash, - deploymentId, - logsDir: path.join(serviceDir, "logs"), - serviceDir, - user: isSelf(service) ? "root" : "drm", - } - ); + await l$`cat ${path.join( + deployerDir, + "service.template" + )} | envsubst > ${path.join(serviceDir, systemdServiceName)}`.env({ + host, + port: port.toString(), + repo, + branch, + commitHash, + deploymentId, + logsDir: path.join(serviceDir, "logs"), + serviceDir, + user: isSelf(service) ? "root" : "drm", + }); await l$`ln -sf ${serviceDir}/${systemdServiceName} ${config.systemServicesDir}/${systemdServiceName}`; // Start!