promote-models.ts 619 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bun
  2. import { $ } from "bun"
  3. import path from "path"
  4. import { ZenData } from "../src/model"
  5. const stage = process.argv[2]
  6. if (!stage) throw new Error("Stage is required")
  7. const root = path.resolve(process.cwd(), "..", "..", "..")
  8. // read the secret
  9. const ret = await $`bun sst secret list`.cwd(root).text()
  10. const value = ret
  11. .split("\n")
  12. .find((line) => line.startsWith("ZEN_MODELS"))
  13. ?.split("=")[1]
  14. if (!value) throw new Error("ZEN_MODELS not found")
  15. // validate value
  16. ZenData.validate(JSON.parse(value))
  17. // update the secret
  18. await $`bun sst secret set ZEN_MODELS ${value} --stage ${stage}`