Skip to content

Commit

Permalink
WIP calculate changed apps
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Aug 25, 2024
1 parent 0af9737 commit 7df2921
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
51 changes: 25 additions & 26 deletions util/ci/transfer-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 7df2921

Please sign in to comment.