Configure encrypted environment for source releases
Verify control plane / verify (push) Canceled after 0s
Verify control plane / verify (pull_request) Canceled after 0s

This commit is contained in:
WebUp Cloud committed 2026-11-08 23:31:17 +08:00
1 parent da93d4fa1c
commit 4401c84f4a
4 files changed
+110 -18

No files matched your search

+28 -3
View File
@@ -26,7 +26,8 @@ const form = reactive({
enabled: true,
});
const command = ref("[]"),
environment = ref("");
environment = ref(""),
sourceEnvironment = ref("");
const publication = ref<{ reviewStatus: string; archived: boolean }>();
const reviewLabels: Record<string, string> = {
PENDING: "待管理员审核",
@@ -81,6 +82,7 @@ function selectProject() {
output.value = "";
error.value = "";
success.value = "";
sourceEnvironment.value = "";
void load();
}
function edit(s?: any) {
@@ -164,6 +166,19 @@ const sourceKeys = new Map<string, string>();
async function deploy(rollbackId?: string, fromSource = false) {
if (!canPublish.value || (!rollbackId && !fromSource && (!hasService.value || hasManagedSource.value)) || busy.value) return;
const id = project.value;
let variables: Record<string, string> | undefined;
if (fromSource && sourceEnvironment.value.trim()) {
try {
const value = JSON.parse(sourceEnvironment.value);
if (!value || Array.isArray(value) || typeof value !== "object" ||
Object.values(value).some(item => typeof item !== "string"))
throw new Error();
variables = value;
} catch {
error.value = "源码运行环境变量必须是 JSON 对象,所有值须为字符串。";
return;
}
}
if (!confirm(rollbackId ? "确认重新发布历史版本?" : fromSource ? "确认从当前 AI 工作区源码构建并发布?" : "确认发布当前服务配置?"))
return;
busy.value = true;
@@ -175,10 +190,13 @@ async function deploy(rollbackId?: string, fromSource = false) {
...(fromSource ? { signal: AbortSignal.timeout(170000) } : {}),
body: body({
idempotencyKey: fromSource ? sourceKeys.get(id) : crypto.randomUUID(),
...(fromSource ? {} : { rollbackId: rollbackId || null }),
...(fromSource ? { environment: variables } : { rollbackId: rollbackId || null }),
}),
});
if (fromSource) sourceKeys.delete(id);
if (fromSource) {
sourceKeys.delete(id);
sourceEnvironment.value = "";
}
success.value = fromSource ? "已保存源码快照,等待自动构建与发布" : "部署已入队";
await load();
} catch (e) {
@@ -272,6 +290,13 @@ onUnmounted(() => clearInterval(timer));
<p v-if="!hasService">可直接从 AI 工作区发布源码。使用已有镜像时,需要先添加服务。</p>
<p v-if="deploying">已有发布任务正在处理。</p>
</div>
<details v-if="project" class="panel form-panel">
<summary>源码运行环境变量</summary>
<label>
<span>JSON 对象。留空保留现有配置,输入 {} 清空。随下一次源码发布生效。</span>
<textarea v-model="sourceEnvironment" :disabled="busy" rows="3" autocomplete="off" spellcheck="false" placeholder='{"VARIABLE":"value"}'></textarea>
</label>
</details>
<section class="project-grid">
<article class="panel project-card" v-for="s in services" :key="s.id">
<div class="project-card-top">