diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2f1c45c20..59b774a0d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -52,6 +52,11 @@ jobs: turbo $changedAppsCommitFilter -F '!~dumili' -F '!~dumili-api' build - name: Retrieve pre-build files + env: + PRODUCTION_SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} + PRODUCTION_SSH_FINGERPRINT: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }} + PRODUCTION_SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }} + PRODUCTION_SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} run: | turbo $changedAppsCommitFilter -F '!~dumili' -F '!~dumili-api' --concurrency 1 prod:transfer-files-pre @@ -64,6 +69,11 @@ jobs: run: | turbo $changedAppsCommitFilter -F '!~dumili' -F '!~dumili-api' --concurrency 1 prod:deploy - - name: Upload files + - name: Send post-build files + env: + PRODUCTION_SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} + PRODUCTION_SSH_FINGERPRINT: ${{ secrets.PRODUCTION_SSH_FINGERPRINT }} + PRODUCTION_SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }} + PRODUCTION_SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} run: | turbo $changedAppsCommitFilter -F '!~dumili' -F '!~dumili-api' --concurrency 1 prod:transfer-files-post diff --git a/util/ci/transfer-files.ts b/util/ci/transfer-files.ts index 96da82502..d737e1423 100644 --- a/util/ci/transfer-files.ts +++ b/util/ci/transfer-files.ts @@ -2,42 +2,41 @@ import SFTPClient from "ssh2-sftp-client"; const { - PRODUCTION_SSH_HOST, - PRODUCTION_SSH_USER, - PRODUCTION_SSH_KEY, + PRODUCTION_SSH_HOST, + PRODUCTION_SSH_USER, + PRODUCTION_SSH_KEY, }: { - PRODUCTION_SSH_HOST: string; - PRODUCTION_SSH_USER: string; - PRODUCTION_SSH_KEY: string; + PRODUCTION_SSH_HOST: string; + PRODUCTION_SSH_USER: string; + PRODUCTION_SSH_KEY: string; } = process.env; const sftp = new SFTPClient(); await sftp.connect({ - host: PRODUCTION_SSH_HOST, - port: 22, - username: PRODUCTION_SSH_USER, - key: PRODUCTION_SSH_KEY, + host: PRODUCTION_SSH_HOST, + username: PRODUCTION_SSH_USER, + privateKey: PRODUCTION_SSH_KEY, }); -const transfers = Bun.argv.splice(2); +const transfers: string[] = Bun.argv.splice(2); for (const transfer of transfers) { - let [sourceFile, targetFile] = transfer.slice(":"); + let [sourceFile, targetFile] = transfer.split(":"); - try { - if (targetFile.indexOf("@") === 0) { - targetFile = `../../${targetFile.replace("@", "")}`; - console.log(`Uploading ${sourceFile} to ${targetFile}`); - // await sftp.put(sourceFile, targetFile); - } else { - sourceFile = `../../${sourceFile.replace("@", "")}`; - console.log(`Downloading ${sourceFile} to ${targetFile}`); - // await sftp.get(sourceFile, targetFile); + try { + if (targetFile.startsWith("@")) { + targetFile = `../../${targetFile.replace("@", "")}`; + console.log(`Uploading ${sourceFile} to ${targetFile}`); + // await sftp.put(sourceFile, targetFile); + } else { + sourceFile = `../../${sourceFile.replace("@", "")}`; + console.log(`Downloading ${sourceFile} to ${targetFile}`); + // await sftp.get(sourceFile, targetFile); + } + } catch (error) { + console.error("Error:", error.message); + } finally { + sftp.end(); } - } catch (error) { - console.error("Error:", error.message); - } finally { - sftp.end(); - } }