This commit is contained in:
Andreas Svanberg 2024-10-30 12:12:31 +01:00
parent ec4194b0a9
commit fce8e62747

12
dist/index.js vendored

@ -51,20 +51,13 @@ function main() {
const owner = gitea.context.repo.owner;
const serverUrl = gitea.context.serverUrl;
const mangledBranchName = branchName.replace(/\//g, '-').replace(/[^a-zA-Z0-9-]/g, '');
const composeFile = core.getInput('compose-file', { required: true });
core.info(`Branch name: ${branchName}`);
core.info(`Repository name: ${repositoryName}`);
core.setOutput('url', branchName);
const issueNumber = gitea.context.issue.number;
core.info(`Issue number: ${issueNumber}`);
core.info(`context.apiUrl: ${gitea.context.apiUrl}`);
core.info('dumping process.env');
Object.keys(process.env).forEach(key => {
let value = process.env[key];
if (key.includes('TOKEN') || key.includes('SECRET') || key.includes('KEY')) {
value = '***';
}
core.info(`process.env[${key}]=${value}`);
});
const api = client.default({
baseUrl: gitea.context.apiUrl,
headers: {
@ -90,9 +83,8 @@ function main() {
fs.writeFileSync('ssh_key', `${sshKey}\n`, { flag: 'w+', mode: "0600" });
const pipedCommand = `pwd | ls -l`;
yield exec.exec('sh', ['-c', `${pipedCommand}`]);
yield exec.exec('cat', ['ssh_key']);
const deployCommand = `\
echo "${serverUrl}/${owner}/${repositoryName}.git ${branchName} ${mangledBranchName}" | \
echo "${serverUrl}/${owner}/${repositoryName}.git ${branchName} ${mangledBranchName} ${composeFile}" | \
ssh -i ssh_key -o StrictHostKeyChecking=accept-new branch.dsv.su.se`;
const deployment = yield exec.getExecOutput('sh', ['-c', deployCommand]);
if (deployment.exitCode != 0) {