summaryrefslogtreecommitdiffhomepage
path: root/packages/console/core/script/promote-models.ts
blob: 1a5cf2fdea37f0b54e78d64115c16f39758cb6b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bun

import { $ } from "bun"
import path from "path"
import { ZenModel } from "../src/model"

const stage = process.argv[2]
if (!stage) throw new Error("Stage is required")

const root = path.resolve(process.cwd(), "..", "..", "..")

// read the secret
const ret = await $`bun sst secret list`.cwd(root).text()
const value = ret
  .split("\n")
  .find((line) => line.startsWith("ZEN_MODELS"))
  ?.split("=")[1]
if (!value) throw new Error("ZEN_MODELS not found")

// validate value
ZenModel.ModelsSchema.parse(JSON.parse(value))

// update the secret
await $`bun sst secret set ZEN_MODELS ${value} --stage ${stage}`