Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(ci): deploy ai-editing-worker to prod on release (#5844)

Wolf Mermelsteinfbdca9538262
diff --git a/.github/workflows/deploy_ai_editing_worker.yml b/.github/workflows/deploy_ai_editing_worker.yml
index 8eb069d8ac..6a306aafe4 100644
--- a/.github/workflows/deploy_ai_editing_worker.yml
+++ b/.github/workflows/deploy_ai_editing_worker.yml
@@ -1,24 +1,37 @@
# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_ai_editing_worker.rs
name: Deploy AI Editing Worker
-'on':
+on:
push:
branches:
- main
paths:
- - '.github/workflows/deploy_ai_editing_worker.yml'
+ - .github/workflows/deploy_ai_editing_worker.yml
- bun.lock
- package.json
- services/ai-editing-worker/**
- packages/collaboration/**
- packages/lexical-core/**
- packages/loro-mirror/**
- workflow_dispatch:
+ workflow_call:
inputs:
environment:
- description: Environment to deploy (dev or prod)
+ required: true
type: string
+ description: The environment to deploy to. e.g. (dev, prod)
+ secrets:
+ CLOUDFLARE_API_TOKEN:
+ required: true
+ workflow_dispatch:
+ inputs:
+ environment:
+ required: true
+ type: choice
default: dev
+ options:
+ - dev
+ - prod
+ description: The environment to deploy to
jobs:
deploy:
name: Deploy to Cloudflare
@@ -44,5 +57,5 @@ jobs:
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
working-directory: services/ai-editing-worker
concurrency:
- group: ${{ github.workflow }}-${{ inputs.environment || 'dev' }}
+ group: deploy-ai-editing-worker-${{ inputs.environment || 'dev' }}
cancel-in-progress: false
diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml
index f055fffebf..a18b60bea6 100644
--- a/.github/workflows/release-production.yml
+++ b/.github/workflows/release-production.yml
@@ -33,6 +33,17 @@ jobs:
environment: prod
secrets: inherit
+ deploy-ai-editing-worker:
+ name: Deploy AI Editing Worker
+ # Calls DSS/search/auth at prod URLs and opens doc sessions against the prod
+ # sync-service, so it ships behind both. It must also move in lockstep with
+ # cloud-storage's EditDocument tool, which picks the worker's model chains.
+ needs: [deploy-cloud-storage, deploy-sync-service]
+ uses: ./.github/workflows/deploy_ai_editing_worker.yml
+ with:
+ environment: prod
+ secrets: inherit
+
build:
name: Build Web App
runs-on: namespace-profile-linux-mid;overrides.cache-tag=web-ci
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_ai_editing_worker.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_ai_editing_worker.rs
index a78b0536b4..d725219568 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_ai_editing_worker.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_ai_editing_worker.rs
@@ -2,20 +2,26 @@
//! Worker (`services/ai-editing-worker`) via wrangler. Generated into
//! `deploy_ai_editing_worker.yml`.
//!
-//! Push to `main` (path-gated) auto-deploys `dev`; `workflow_dispatch` picks the
-//! target env via a `string` input (`dev` or `prod`, defaults to `dev`). Runs on
-//! the small profile — a bun install plus `wrangler deploy`, no Nix or cache
-//! volume needed.
-
-use std::collections::HashMap;
+//! Push to `main` (path-gated) auto-deploys `dev`; prod deploys come through
+//! `release-production`, which calls this workflow with `environment: prod` —
+//! the same split [`crate::workflows::deploy_sync_service`] uses. Manual
+//! `workflow_dispatch` picks either env from a `choice` input. Runs on the small
+//! profile — a bun install plus `wrangler deploy`, no Nix or cache volume
+//! needed.
+//!
+//! Prod used to be dispatch-only, and nothing ever dispatched it — the worker ran
+//! ten-day-old code while `release-production` shipped its Rust caller.
+use anyhow::Result;
use gh_workflow::{
- Concurrency, Event, Expression, Job, Push, Run, Step, Use, Workflow, WorkflowDispatch,
- WorkflowDispatchInput,
+ Concurrency, Event, Expression, Job, Push, Run, Step, Use, Workflow, WorkflowCall,
+ WorkflowDispatch,
};
use crate::workflows::{runners, steps, vars};
+const ENVIRONMENT: &str = "${{ inputs.environment || 'dev' }}";
+
/// Build the workflow.
pub fn deploy_ai_editing_worker() -> Workflow {
Workflow::new("Deploy AI Editing Worker")
@@ -35,26 +41,58 @@ pub fn deploy_ai_editing_worker() -> Workflow {
.add_path(xtask_paths::repo_glob!("packages/lexical-core/**"))
.add_path(xtask_paths::repo_glob!("packages/loro-mirror/**")),
)
- .workflow_dispatch(WorkflowDispatch::default().inputs(HashMap::from([(
- "environment".to_string(),
- // Struct literal, not the builder: the `Setters`-derived
- // `default` setter collides with `Default::default()`.
- WorkflowDispatchInput {
- description: "Environment to deploy (dev or prod)".to_string(),
- required: false,
- input_type: "string".to_string(),
- default: Some("dev".to_string()),
- },
- )]))))
+ // The `workflow_call` / `workflow_dispatch` input blocks are filled
+ // in by `patch` below.
+ .workflow_dispatch(WorkflowDispatch::default())
+ .workflow_call(WorkflowCall::default()))
.concurrency(
- Concurrency::new(Expression::new(
- "${{ github.workflow }}-${{ inputs.environment || 'dev' }}",
- ))
+ // Literal prefix rather than `github.workflow`: for workflow_call
+ // runs that expression expands to the *caller's* name.
+ Concurrency::new(Expression::new(format!(
+ "deploy-ai-editing-worker-{ENVIRONMENT}"
+ )))
.cancel_in_progress(false),
)
.add_job("deploy", deploy())
}
+/// Input blocks `gh_workflow` cannot express: a `choice` dispatch input, and the
+/// `workflow_call` contract `release-production` deploys prod through.
+pub fn patch(root: &mut serde_yaml::Value) -> Result<()> {
+ let on = root
+ .get_mut("on")
+ .and_then(serde_yaml::Value::as_mapping_mut)
+ .ok_or_else(|| anyhow::anyhow!("rendered workflow has no `on` mapping"))?;
+ on.insert(
+ "workflow_call".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ inputs:
+ environment:
+ required: true
+ type: string
+ description: The environment to deploy to. e.g. (dev, prod)
+ secrets:
+ CLOUDFLARE_API_TOKEN:
+ required: true
+ "#})?,
+ );
+ on.insert(
+ "workflow_dispatch".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ inputs:
+ environment:
+ required: true
+ type: choice
+ default: 'dev'
+ options:
+ - dev
+ - prod
+ description: The environment to deploy to
+ "#})?,
+ );
+ Ok(())
+}
+
fn deploy() -> Job {
Job::default()
.name("Deploy to Cloudflare")
@@ -77,11 +115,12 @@ fn install_deps() -> Step<Run> {
}
fn deploy_step() -> Step<Run> {
- // On push, `inputs.environment` is empty, so this deploys `dev`. Manual
- // dispatch picks dev or prod. `deploy-<env>` regenerates the sandbox before
- // `wrangler deploy` (see services/ai-editing-worker/package.json).
+ // On push, `inputs.environment` is empty, so this deploys `dev`. Dispatch and
+ // `release-production` pass it explicitly. `deploy-<env>` regenerates the
+ // sandbox before `wrangler deploy` (see
+ // services/ai-editing-worker/package.json).
Step::new("Deploy with wrangler")
- .run("bun run deploy-${{ inputs.environment || 'dev' }}")
+ .run(format!("bun run deploy-{ENVIRONMENT}"))
.working_directory(xtask_paths::repo_dir!("services/ai-editing-worker"))
.add_env(("CLOUDFLARE_API_TOKEN", vars::CLOUDFLARE_API_TOKEN))
.add_env(("CLOUDFLARE_ACCOUNT_ID", vars::CLOUDFLARE_ACCOUNT_ID))
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
index 2f6861c687..45c69eac34 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
@@ -182,7 +182,12 @@ const WORKFLOWS: &[WorkflowFile] = &[
WorkflowFile {
slug: "deploy_ai_editing_worker",
file_name: "deploy_ai_editing_worker.yml",
- render_yaml: || render_gh_workflow(deploy_ai_editing_worker::deploy_ai_editing_worker)(),
+ render_yaml: || {
+ render_patched(
+ deploy_ai_editing_worker::deploy_ai_editing_worker,
+ deploy_ai_editing_worker::patch,
+ )
+ },
},
WorkflowFile {
slug: "deploy_all_services",