Skip to content

Commit 0bb1f57

Browse files
committed
fix: deploy key based deployments
1 parent d006edc commit 0bb1f57

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

app/Jobs/ApplicationDeploymentJob.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,14 +1442,24 @@ private function check_git_if_build_needed()
14421442
if ($this->pull_request_id !== 0) {
14431443
$local_branch = "pull/{$this->pull_request_id}/head";
14441444
}
1445-
$private_key = $this->application->privateKey?->getKeyLocation();
1445+
$private_key = data_get($this->application, 'private_key.private_key');
14461446
if ($private_key) {
1447+
$private_key = base64_encode($private_key);
14471448
$this->execute_remote_command(
14481449
[
1449-
executeInDocker($this->deployment_uuid, "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i {$private_key}\" git ls-remote {$this->fullRepoUrl} {$local_branch}"),
1450+
executeInDocker($this->deployment_uuid, 'mkdir -p /root/.ssh'),
1451+
],
1452+
[
1453+
executeInDocker($this->deployment_uuid, "echo '{$private_key}' | base64 -d | tee /root/.ssh/id_rsa > /dev/null"),
1454+
],
1455+
[
1456+
executeInDocker($this->deployment_uuid, 'chmod 600 /root/.ssh/id_rsa'),
1457+
],
1458+
[
1459+
executeInDocker($this->deployment_uuid, "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" git ls-remote {$this->fullRepoUrl} {$local_branch}"),
14501460
'hidden' => true,
14511461
'save' => 'git_commit_sha',
1452-
],
1462+
]
14531463
);
14541464
} else {
14551465
$this->execute_remote_command(

0 commit comments

Comments
 (0)