-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overwrite main with preview content (#96)
* overwrite main with preview content * deleted test folder * deleted old part store
- Loading branch information
1 parent
b341468
commit 8046f88
Showing
126 changed files
with
5,144 additions
and
3,182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
push: | ||
branches: | ||
- preview | ||
pull_request: | ||
|
||
jobs: | ||
check: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { $, env, file } from "bun"; | ||
|
||
// Validate required environment variables | ||
console.log("🚀 Starting upload script"); | ||
const filePath = process.argv[2]; | ||
const force = process.argv[3] === "--force"; | ||
const POSTGRES_USER = env.POSTGRES_USER; | ||
const POSTGRES_DB = env.POSTGRES_DB; | ||
|
||
if (!filePath) throw new Error("❌ Missing file path argument. Please provide a file path when running the script."); | ||
if (await file(filePath).exists() && !force) throw new Error(`❌ File found at: ${filePath}. Refusing to overwrite ${filePath}. use --force to overwrite the file`); | ||
if (!POSTGRES_USER) throw new Error("❌ Missing environment variable: POSTGRES_USER") | ||
if (!POSTGRES_DB ) throw new Error("❌ Missing environment variable: POSTGRES_DB") | ||
if (force) console.warn(`⚠️ Using --force flag. will overwrite`); | ||
|
||
console.info(`📁 File path argument received: ${filePath}`); | ||
|
||
// Execute backup command using Bun's shell | ||
const backup = $ | ||
`docker compose exec timescaledb pg_dump \ | ||
-U ${POSTGRES_USER} \ | ||
-d ${POSTGRES_DB} \ | ||
--format=custom > ${filePath}`; | ||
|
||
console.log(`⏳ Starting Backup at: ${filePath}`); | ||
|
||
await backup | ||
|
||
console.log(`✅ Backup successfully created at: ${filePath}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { S3Client, env, file } from "bun"; | ||
|
||
console.log("🚀 Starting S3 download script"); | ||
|
||
const S3_ACCESS_KEY_ID = env.S3_ACCESS_KEY_ID; | ||
const S3_SECRET_ACCESS_KEY = env.S3_SECRET_ACCESS_KEY; | ||
const S3_BUCKET = env.S3_BUCKET ?? "local"; | ||
const S3_ENDPOINT = env.S3_ENDPOINT ?? "http://localhost:9000"; | ||
const s3FilePath = process.argv[2]; | ||
const localFilePath = process.argv[3]; | ||
|
||
if (!s3FilePath) throw new Error("❌ Missing s3FilePath argument. Provide an s3FilePath key to download."); | ||
if (!localFilePath) throw new Error("❌ Missing S3 key argument. Provide an S3 object key to download."); | ||
if (!S3_ACCESS_KEY_ID) throw new Error("❌ Missing environment variable: S3_ACCESS_KEY_ID"); | ||
if (!S3_SECRET_ACCESS_KEY) throw new Error("❌ Missing environment variable: S3_SECRET_ACCESS_KEY"); | ||
if (!S3_BUCKET) console.warn("⚠️ S3_BUCKET environment variable not set, using default 'local'."); | ||
if (!S3_ENDPOINT) console.warn("⚠️ S3_ENDPOINT environment variable not set, using default 'http://localhost:9000'."); | ||
|
||
// Initialize clients | ||
console.log(`⏳ Initializing S3 from bucket ${S3_BUCKET} and local file`) | ||
const localFile = file(localFilePath); | ||
const minio = new S3Client({ | ||
accessKeyId: S3_ACCESS_KEY_ID, | ||
secretAccessKey: S3_SECRET_ACCESS_KEY, | ||
bucket: S3_BUCKET, | ||
endpoint: S3_ENDPOINT, | ||
}); | ||
|
||
if (await localFile.exists()) throw new Error(`❌ Exsisting file found at path: ${localFilePath}. Not allowed to overwrite`); | ||
|
||
const s3File = minio.file(s3FilePath); | ||
|
||
if (!await s3File.exists()) throw new Error(`❌ File "${s3FilePath}" not found in S3 bucket`); | ||
|
||
|
||
console.log(`📥 Downloading "${s3FilePath}" from bucket "${S3_BUCKET}"...`); | ||
const content = await s3File.arrayBuffer(); | ||
await Bun.write(localFile, content); | ||
|
||
console.log(`✅ Successfully saved to: ${localFilePath}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { $, env, file } from "bun"; | ||
|
||
// Validate required environment variables | ||
console.log("🚀 Starting upload script"); | ||
const filePath = process.argv[2]; | ||
const force = process.argv[3] === "--force"; | ||
const POSTGRES_USER = env.POSTGRES_USER; | ||
const POSTGRES_DB = env.POSTGRES_DB; | ||
|
||
if (!filePath) throw new Error("❌ Missing file path argument. Please provide a file path when running the script."); | ||
if (await file(filePath).exists() && !force) throw new Error(`❌ File found at: ${filePath}. Refusing to overwrite ${filePath}. use --force to overwrite the file`); | ||
if (!POSTGRES_USER) throw new Error("❌ Missing environment variable: POSTGRES_USER") | ||
if (!POSTGRES_DB ) throw new Error("❌ Missing environment variable: POSTGRES_DB") | ||
if (force) console.warn(`⚠️ Using --force flag. will overwrite`); | ||
|
||
console.info(`📁 File path argument received: ${filePath}`); | ||
|
||
// Execute backup command using Bun's shell | ||
|
||
const preRestore = $ | ||
`docker compose exec timescaledb pg_dump \ | ||
-U ${POSTGRES_USER} \ | ||
-d ${POSTGRES_DB} \ | ||
--format=custom > ${filePath}`; | ||
|
||
const restore = $ | ||
`docker compose exec timescaledb pg_dump \ | ||
-U ${POSTGRES_USER} \ | ||
-d ${POSTGRES_DB} \ | ||
--format=custom > ${filePath}`; | ||
|
||
const postRestore = $ | ||
`docker compose exec timescaledb pg_dump \ | ||
-U ${POSTGRES_USER} \ | ||
-d ${POSTGRES_DB} \ | ||
--format=custom > ${filePath}`; | ||
|
||
|
||
console.log(`⏳ Starting Backup at: ${filePath}`); | ||
await preRestore | ||
await restore | ||
await postRestore | ||
|
||
console.log(`✅ Backup successfully created at: ${filePath}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { S3Client, write, env, file } from "bun"; | ||
import path from 'path'; | ||
|
||
console.log("🚀 Starting S3 upload script"); | ||
|
||
const S3_ACCESS_KEY_ID = env.S3_ACCESS_KEY_ID; | ||
const S3_SECRET_ACCESS_KEY = env.S3_SECRET_ACCESS_KEY; | ||
const S3_BUCKET = env.S3_BUCKET ?? "local"; | ||
const S3_ENDPOINT = env.S3_ENDPOINT ?? "http://localhost:9000"; | ||
const filePath = process.argv[2]; | ||
const inputFile = file(filePath); | ||
|
||
if (!filePath) throw new Error("❌ Missing file path argument. Please provide a file path when running the script."); | ||
if (!await inputFile.exists()) throw new Error(`❌ File not found at path: ${filePath}`); | ||
if (!S3_ACCESS_KEY_ID) throw new Error("❌ Missing environment variable: S3_ACCESS_KEY_ID"); | ||
if (!S3_SECRET_ACCESS_KEY) throw new Error("❌ Missing environment variable: S3_SECRET_ACCESS_KEY"); | ||
if (!S3_BUCKET) console.warn("⚠️ S3_BUCKET environment variable is not set, using default 'local'."); | ||
if (!S3_ENDPOINT) console.warn("⚠️ S3_ENDPOINT environment variable is not set, using default 'http://localhost:9000'."); | ||
|
||
|
||
console.info(`📁 File path argument received: ${filePath}`); | ||
|
||
const fileContent = await inputFile.arrayBuffer(); | ||
const fileName = path.basename(filePath); | ||
|
||
const minio = new S3Client({ | ||
accessKeyId: S3_ACCESS_KEY_ID, | ||
secretAccessKey: S3_SECRET_ACCESS_KEY, | ||
bucket: S3_BUCKET, | ||
endpoint: S3_ENDPOINT, | ||
}); | ||
|
||
const metadata = minio.file(fileName); | ||
|
||
console.log(`📤 Uploading "${fileName}" to S3 bucket "${S3_BUCKET}"...`); | ||
await write(metadata, fileContent); | ||
|
||
console.log(`🎉 Uploaded "${fileName}" to S3 successfully!`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.