2
0

promote-models.ts 858 B

123456789101112131415161718192021222324252627282930
  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 value1 = ret
  11. .split("\n")
  12. .find((line) => line.startsWith("ZEN_MODELS1"))
  13. ?.split("=")[1]
  14. const value2 = ret
  15. .split("\n")
  16. .find((line) => line.startsWith("ZEN_MODELS2"))
  17. ?.split("=")[1]
  18. if (!value1) throw new Error("ZEN_MODELS1 not found")
  19. if (!value2) throw new Error("ZEN_MODELS2 not found")
  20. // validate value
  21. ZenData.validate(JSON.parse(value1 + value2))
  22. // update the secret
  23. await $`bun sst secret set ZEN_MODELS1 ${value1} --stage ${stage}`
  24. await $`bun sst secret set ZEN_MODELS2 ${value2} --stage ${stage}`