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.

feat(ci): single deploy_on_push workflow for dev (#5532)

Will Hutchinson5b5d89a25456
diff --git a/.github/workflows/cancel_stuck_cloud_storage_deploys.yml b/.github/workflows/cancel_stuck_cloud_storage_deploys.yml
index dea6411f06..3941e567cf 100644
--- a/.github/workflows/cancel_stuck_cloud_storage_deploys.yml
+++ b/.github/workflows/cancel_stuck_cloud_storage_deploys.yml
@@ -24,7 +24,7 @@ jobs:
name: Cancel runs stuck queued or in_progress past threshold
runs-on: namespace-profile-linux-tiny-no-cache
env:
- WORKFLOW_FILE: deploy_cloud_storage_on_push.yml
+ WORKFLOW_FILE: deploy_on_push.yml
MAX_AGE_MINUTES: ${{ inputs.max-age-minutes || '90' }}
DRY_RUN: ${{ inputs.dry-run || 'false' }}
GH_TOKEN: ${{ github.token }}
diff --git a/.github/workflows/deploy_cloud_storage_on_push.yml b/.github/workflows/deploy_cloud_storage_on_push.yml
deleted file mode 100644
index 47bc373b57..0000000000
--- a/.github/workflows/deploy_cloud_storage_on_push.yml
+++ /dev/null
@@ -1,51 +0,0 @@
-# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).
-# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_cloud_storage_on_push.rs
-name: Deploy Cloud Storage Services on Push
-on:
- push:
- branches:
- - main
- paths:
- - Cargo.toml
- - Cargo.lock
- - Cross.toml
- - clippy.toml
- - deny.toml
- - rust-toolchain.toml
- - .cargo/**
- - .config/**
- - .sqlx/**
- - crates/**
- - services/**
- - tooling/xtask/**
- - tooling/just/**
- - tooling/scripts/**
- - static_assets/**
- - docker/**
- - nix/**
- - nix-support/**
- - infra/**
- - .github/workflows/deploy_cloud_storage_on_push.yml
- - .github/workflows/deploy_all_services.yml
- - .github/actions/deploy-cloud-storage-pulumi/**
- - .github/actions/setup-nix/**
- - .github/actions/teardown-nix/**
- - .github/actions/migrate-cloud-storage-db/**
- - .github/scripts/build-cloud-storage-lambdas-nix.sh
- - .github/services-config.json
- - .github/workspace-dep-closures.json
- - flake.nix
- - flake.lock
-jobs:
- deploy-all:
- name: Deploy Cloud Storage Services
- uses: ./.github/workflows/deploy_all_services.yml
- with:
- environment: dev
- secrets:
- AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
- DD_API_KEY: ${{ secrets.DD_API_KEY }}
- NIX_CACHE_SIGNING_KEY: ${{ secrets.NIX_CACHE_SIGNING_KEY }}
diff --git a/.github/workflows/deploy_on_push.yml b/.github/workflows/deploy_on_push.yml
new file mode 100644
index 0000000000..ea7bd50d12
--- /dev/null
+++ b/.github/workflows/deploy_on_push.yml
@@ -0,0 +1,73 @@
+# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).
+# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_on_push.rs
+name: Deploy on Push
+on:
+ push:
+ branches:
+ - main
+jobs:
+ check-to-deploy:
+ runs-on: namespace-profile-linux-tiny-no-cache
+ outputs:
+ cloud-storage: ${{ steps.changes.outputs.cloud-storage }}
+ sync-service: ${{ steps.changes.outputs.sync-service }}
+ web-app: ${{ steps.changes.outputs.web-app }}
+ steps:
+ - name: Checkout Repo
+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
+ - id: changes
+ name: Check changed paths
+ uses: whutchinson98/diff-checker-action@d25a22ee8f84f5e44abda3027c80c2e6d71f68a6
+ with:
+ token: ${{ github.token }}
+ diff: |-
+ cloud-storage: ./Cargo.toml ./Cargo.lock ./Cross.toml ./clippy.toml ./deny.toml ./rust-toolchain.toml ./.cargo/** ./.config/** ./.sqlx/** ./crates/** ./services/** ./tooling/xtask/** ./tooling/just/** ./tooling/scripts/** ./static_assets/** ./docker/** ./nix/** ./nix-support/** ./infra/** ./.github/workflows/deploy_on_push.yml ./.github/workflows/deploy_all_services.yml ./.github/actions/deploy-cloud-storage-pulumi/** ./.github/actions/setup-nix/** ./.github/actions/teardown-nix/** ./.github/actions/migrate-cloud-storage-db/** ./.github/scripts/build-cloud-storage-lambdas-nix.sh ./.github/services-config.json ./.github/workspace-dep-closures.json ./flake.nix ./flake.lock
+ sync-service: ./services/sync-service/** ./crates/macro_sync_service_jwt/** ./Cargo.toml ./Cargo.lock ./rust-toolchain.toml ./.github/workflows/deploy_on_push.yml ./.github/workflows/deploy_sync_service.yml
+ web-app: ./infra/stacks/web-app/** ./.github/workflows/deploy_on_push.yml ./.github/workflows/deploy_web_app.yml ./package.json ./bun.lock ./apps/web/** ./packages/** ./crates/client/cache-core/** ./crates/client/cache-idb/** ./crates/client/cache-wasm/** ./static_assets/schema.graphql ./Cargo.toml ./Cargo.lock ./rust-toolchain.toml
+ deploy-cloud-storage:
+ needs:
+ - check-to-deploy
+ if: ${{ needs.check-to-deploy.outputs.cloud-storage == 'true' }}
+ name: Deploy Cloud Storage Services
+ uses: ./.github/workflows/deploy_all_services.yml
+ with:
+ environment: dev
+ secrets:
+ AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
+ DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
+ DD_API_KEY: ${{ secrets.DD_API_KEY }}
+ NIX_CACHE_SIGNING_KEY: ${{ secrets.NIX_CACHE_SIGNING_KEY }}
+ deploy-sync-service:
+ needs:
+ - check-to-deploy
+ - deploy-cloud-storage
+ if: ${{ !failure() && !cancelled() && needs.check-to-deploy.outputs.sync-service == 'true' }}
+ name: Deploy Sync Service
+ uses: ./.github/workflows/deploy_sync_service.yml
+ with:
+ environment: dev
+ secrets:
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ deploy-web-app:
+ needs:
+ - check-to-deploy
+ - deploy-cloud-storage
+ if: ${{ !failure() && !cancelled() && needs.check-to-deploy.outputs.web-app == 'true' }}
+ name: Deploy Web App
+ uses: ./.github/workflows/deploy_web_app.yml
+ with:
+ notify: false
+ environment: dev
+ secrets:
+ AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
+ DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
+ DD_API_KEY: ${{ secrets.DD_API_KEY }}
+ SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}
+ POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
+concurrency:
+ group: ${{ github.workflow }}
+ cancel-in-progress: false
diff --git a/.github/workflows/deploy_sync_service.yml b/.github/workflows/deploy_sync_service.yml
index 95c11883b5..c4c3ba9d65 100644
--- a/.github/workflows/deploy_sync_service.yml
+++ b/.github/workflows/deploy_sync_service.yml
@@ -2,16 +2,6 @@
# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs
name: Deploy Sync Service
on:
- push:
- branches:
- - main
- paths:
- - .github/workflows/deploy_sync_service.yml
- - services/sync-service/**
- - crates/macro_sync_service_jwt/**
- - Cargo.toml
- - Cargo.lock
- - rust-toolchain.toml
workflow_call:
inputs:
environment:
diff --git a/.github/workflows/deploy_web_app_dev_push.yml b/.github/workflows/deploy_web_app_dev_push.yml
deleted file mode 100644
index fd972eaf30..0000000000
--- a/.github/workflows/deploy_web_app_dev_push.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).
-# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app_dev_push.rs
-name: Deploy web app dev on push to main
-on:
- push:
- branches:
- - main
-jobs:
- check-to-deploy:
- runs-on: namespace-profile-linux-tiny-no-cache
- outputs:
- web-app: ${{ steps.changes.outputs.web-app }}
- steps:
- - name: Checkout Repo
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
- - id: changes
- name: Check changed paths
- uses: whutchinson98/diff-checker-action@d25a22ee8f84f5e44abda3027c80c2e6d71f68a6
- with:
- token: ${{ github.token }}
- diff: 'web-app: ./infra/stacks/web-app/** ./package.json ./bun.lock ./apps/web/** ./packages/** ./crates/client/cache-core/** ./crates/client/cache-idb/** ./crates/client/cache-wasm/** ./static_assets/schema.graphql ./Cargo.toml ./Cargo.lock ./rust-toolchain.toml'
- deploy_web_app:
- needs:
- - check-to-deploy
- if: ${{ needs.check-to-deploy.outputs.web-app == 'true' }}
- uses: ./.github/workflows/deploy_web_app.yml
- with:
- notify: false
- environment: dev
- secrets:
- AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
- DD_API_KEY: ${{ secrets.DD_API_KEY }}
- SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}
- POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
-concurrency:
- group: ${{ github.workflow }}
- cancel-in-progress: false
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/cancel_stuck_cloud_storage_deploys.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/cancel_stuck_cloud_storage_deploys.rs
index f9b6fb3955..c4c833ee35 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/cancel_stuck_cloud_storage_deploys.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/cancel_stuck_cloud_storage_deploys.rs
@@ -1,5 +1,5 @@
//! `Cancel Stuck Cloud Storage Deploys` — hourly cron that cancels
-//! `deploy-cloud-storage-on-push` runs stuck queued/in_progress past a
+//! `deploy_on_push` runs stuck queued/in_progress past a
//! threshold. Generated into `cancel_stuck_cloud_storage_deploys.yml`
//! (replaces the hand-written `cancel-stuck-cloud-storage-deploys.yml`).
//!
@@ -57,8 +57,8 @@ fn cancel_stuck() -> Job {
.runs_on(runners::Runner::TinyNoCache.to_string())
.timeout_minutes(5u32)
// Keep in sync with the deploy trigger's generated filename
- // (see deploy_cloud_storage_on_push.rs).
- .add_env(("WORKFLOW_FILE", "deploy_cloud_storage_on_push.yml"))
+ // (see deploy_on_push.rs).
+ .add_env(("WORKFLOW_FILE", "deploy_on_push.yml"))
.add_env(("MAX_AGE_MINUTES", "${{ inputs.max-age-minutes || '90' }}"))
.add_env(("DRY_RUN", "${{ inputs.dry-run || 'false' }}"))
.add_env(("GH_TOKEN", "${{ github.token }}"))
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_all_services.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_all_services.rs
index 5dd82367ca..0276c394e1 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_all_services.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_all_services.rs
@@ -2,7 +2,7 @@
//! two shared dep closures onto sticky disks, fan a build matrix out per
//! service (binaries via crane, lambdas via crane + cargo-zigbuild), hand the
//! artifacts off through Namespace artifact storage, run DB migrations, then
-//! deploy every service via Pulumi. Called by `deploy_cloud_storage_on_push`
+//! deploy every service via Pulumi. Called by `deploy_on_push`
//! (dev) and `release-production` (prod), and manually dispatchable.
//! Generated into `deploy_all_services.yml` (replaces the hand-written
//! `deploy-all-services.yml`).
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_cloud_storage_on_push.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_cloud_storage_on_push.rs
deleted file mode 100644
index 8e77a9c3d6..0000000000
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_cloud_storage_on_push.rs
+++ /dev/null
@@ -1,102 +0,0 @@
-//! `Deploy Cloud Storage Services on Push` — thin trigger: every push to main
-//! touching the Rust services (or the deploy machinery) deploys all services
-//! to dev via the shared [`crate::workflows::deploy_all_services`] pipeline —
-//! the same warm sticky-disk nix builds, crane/zigbuild lambdas, and handoff
-//! topology used by manual dispatches and prod releases. Generated into
-//! `deploy_cloud_storage_on_push.yml` (replaces the hand-written
-//! `deploy-cloud-storage-on-push.yml`; keep
-//! [`crate::workflows::cancel_stuck_cloud_storage_deploys`]'s `WORKFLOW_FILE`
-//! in sync with this filename).
-//!
-//! NOTE: deliberately no concurrency block here. The called workflow's own
-//! top-level group (`deploy-all-services-${{ inputs.environment }}`) IS
-//! honored for workflow_call runs and is what serializes push deploys against
-//! manual dev dispatches (running deploys finish; queued pushes coalesce to
-//! the newest). Declaring the same group in this wrapper makes GitHub detect
-//! a self-deadlock ("between a top level workflow and ...") and cancel the
-//! run.
-
-use anyhow::Result;
-use gh_workflow::{Event, Job, Push, Workflow};
-
-/// Build the workflow. The caller job's `with:`/`secrets:` are filled in by
-/// [`patch`].
-pub fn deploy_cloud_storage_on_push() -> Workflow {
- Workflow::new("Deploy Cloud Storage Services on Push")
- .on(Event::default().push(
- Push::default()
- .add_branch("main")
- .add_path(xtask_paths::repo_glob!("Cargo.toml"))
- .add_path(xtask_paths::repo_glob!("Cargo.lock"))
- .add_path(xtask_paths::repo_glob!("Cross.toml"))
- .add_path(xtask_paths::repo_glob!("clippy.toml"))
- .add_path(xtask_paths::repo_glob!("deny.toml"))
- .add_path(xtask_paths::repo_glob!("rust-toolchain.toml"))
- .add_path(xtask_paths::repo_glob!(".cargo/**"))
- .add_path(xtask_paths::repo_glob!(".config/**"))
- .add_path(xtask_paths::repo_glob!(".sqlx/**"))
- .add_path(xtask_paths::repo_glob!("crates/**"))
- .add_path(xtask_paths::repo_glob!("services/**"))
- .add_path(xtask_paths::repo_glob!("tooling/xtask/**"))
- .add_path(xtask_paths::repo_glob!("tooling/just/**"))
- .add_path(xtask_paths::repo_glob!("tooling/scripts/**"))
- .add_path(xtask_paths::repo_glob!("static_assets/**"))
- .add_path(xtask_paths::repo_glob!("docker/**"))
- .add_path(xtask_paths::repo_glob!("nix/**"))
- .add_path(xtask_paths::repo_glob!("nix-support/**"))
- .add_path(xtask_paths::repo_glob!("infra/**"))
- .add_path(xtask_paths::repo_glob!(
- ".github/workflows/deploy_cloud_storage_on_push.yml"
- ))
- .add_path(xtask_paths::repo_glob!(
- ".github/workflows/deploy_all_services.yml"
- ))
- .add_path(xtask_paths::repo_glob!(
- ".github/actions/deploy-cloud-storage-pulumi/**"
- ))
- .add_path(xtask_paths::repo_glob!(".github/actions/setup-nix/**"))
- .add_path(xtask_paths::repo_glob!(".github/actions/teardown-nix/**"))
- .add_path(xtask_paths::repo_glob!(
- ".github/actions/migrate-cloud-storage-db/**"
- ))
- .add_path(xtask_paths::repo_glob!(
- ".github/scripts/build-cloud-storage-lambdas-nix.sh"
- ))
- .add_path(xtask_paths::repo_glob!(".github/services-config.json"))
- .add_path(xtask_paths::repo_glob!(
- ".github/workspace-dep-closures.json"
- ))
- .add_path(xtask_paths::repo_glob!("flake.nix"))
- .add_path(xtask_paths::repo_glob!("flake.lock")),
- ))
- .add_job("deploy-all", deploy_all())
-}
-
-/// Add the caller job's `with:` and explicit `secrets:` map, and drop the
-/// `runs-on` that `Job::default()` injects (invalid alongside `uses:`).
-pub fn patch(root: &mut serde_yaml::Value) -> Result<()> {
- let job = crate::workflows::job_mut(root, "deploy-all")?;
- job.remove("runs-on");
- job.insert(
- "with".into(),
- crate::workflows::yaml_fragment("environment: dev")?,
- );
- job.insert(
- "secrets".into(),
- crate::workflows::yaml_fragment(indoc::indoc! {r#"
- AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
- DD_API_KEY: ${{ secrets.DD_API_KEY }}
- NIX_CACHE_SIGNING_KEY: ${{ secrets.NIX_CACHE_SIGNING_KEY }}
- "#})?,
- );
- Ok(())
-}
-
-fn deploy_all() -> Job {
- Job::default()
- .name("Deploy Cloud Storage Services")
- .uses("./.github/workflows/deploy_all_services.yml")
-}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_on_push.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_on_push.rs
new file mode 100644
index 0000000000..fafecf72c9
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_on_push.rs
@@ -0,0 +1,239 @@
+//! `Deploy on Push` — the single push-to-main dev deploy pipeline. Mirrors the
+//! production release flow (cloud storage first, then the sync service and web
+//! app), except every stage is gated behind the `check-to-deploy` path diff so
+//! only the stages whose inputs actually changed deploy — the release always
+//! deploys everything. Replaces the separate `deploy_cloud_storage_on_push`
+//! and `deploy_web_app_dev_push` workflows. Generated into `deploy_on_push.yml`
+//! (keep [`crate::workflows::cancel_stuck_cloud_storage_deploys`]'s
+//! `WORKFLOW_FILE` in sync with this filename).
+//!
+//! NOTE: the top-level concurrency group deliberately differs from the called
+//! workflows' literal groups (`deploy-all-services-dev`, `deploy-web-app-dev`,
+//! `deploy-sync-service-dev`) — declaring the *same* group in a wrapper and
+//! its called workflow makes GitHub detect a self-deadlock and cancel the run.
+//! The called workflows' groups are still what serialize these push deploys
+//! against manual dispatches of the individual pipelines.
+
+use anyhow::Result;
+use gh_workflow::{Concurrency, Event, Expression, Job, Push, Step, Use, Workflow};
+use xtask_paths::RepoGlob;
+
+use crate::workflows::{runners, web_artifact_paths};
+
+/// Repository inputs that can change the deployed cloud-storage services —
+/// the trigger paths of the replaced `deploy_cloud_storage_on_push` workflow,
+/// expressed as a diff-checker group so the other stages can share one
+/// push-to-main trigger.
+const CLOUD_STORAGE_PATHS: &[RepoGlob<'static>] = &[
+ xtask_paths::repo_glob!("Cargo.toml"),
+ xtask_paths::repo_glob!("Cargo.lock"),
+ xtask_paths::repo_glob!("Cross.toml"),
+ xtask_paths::repo_glob!("clippy.toml"),
+ xtask_paths::repo_glob!("deny.toml"),
+ xtask_paths::repo_glob!("rust-toolchain.toml"),
+ xtask_paths::repo_glob!(".cargo/**"),
+ xtask_paths::repo_glob!(".config/**"),
+ xtask_paths::repo_glob!(".sqlx/**"),
+ xtask_paths::repo_glob!("crates/**"),
+ xtask_paths::repo_glob!("services/**"),
+ xtask_paths::repo_glob!("tooling/xtask/**"),
+ xtask_paths::repo_glob!("tooling/just/**"),
+ xtask_paths::repo_glob!("tooling/scripts/**"),
+ xtask_paths::repo_glob!("static_assets/**"),
+ xtask_paths::repo_glob!("docker/**"),
+ xtask_paths::repo_glob!("nix/**"),
+ xtask_paths::repo_glob!("nix-support/**"),
+ xtask_paths::repo_glob!("infra/**"),
+ xtask_paths::repo_glob!(".github/workflows/deploy_on_push.yml"),
+ xtask_paths::repo_glob!(".github/workflows/deploy_all_services.yml"),
+ xtask_paths::repo_glob!(".github/actions/deploy-cloud-storage-pulumi/**"),
+ xtask_paths::repo_glob!(".github/actions/setup-nix/**"),
+ xtask_paths::repo_glob!(".github/actions/teardown-nix/**"),
+ xtask_paths::repo_glob!(".github/actions/migrate-cloud-storage-db/**"),
+ xtask_paths::repo_glob!(".github/scripts/build-cloud-storage-lambdas-nix.sh"),
+ xtask_paths::repo_glob!(".github/services-config.json"),
+ xtask_paths::repo_glob!(".github/workspace-dep-closures.json"),
+ xtask_paths::repo_glob!("flake.nix"),
+ xtask_paths::repo_glob!("flake.lock"),
+];
+
+/// Inputs that can change the deployed sync-service worker — the push trigger
+/// paths the [`crate::workflows::deploy_sync_service`] workflow used before it
+/// became call/dispatch-only.
+const SYNC_SERVICE_PATHS: &[RepoGlob<'static>] = &[
+ xtask_paths::repo_glob!("services/sync-service/**"),
+ xtask_paths::repo_glob!("crates/macro_sync_service_jwt/**"),
+ xtask_paths::repo_glob!("Cargo.toml"),
+ xtask_paths::repo_glob!("Cargo.lock"),
+ xtask_paths::repo_glob!("rust-toolchain.toml"),
+ xtask_paths::repo_glob!(".github/workflows/deploy_on_push.yml"),
+ xtask_paths::repo_glob!(".github/workflows/deploy_sync_service.yml"),
+];
+
+/// Build the workflow. The caller jobs' `with:`/`secrets:` are filled in by
+/// [`patch`].
+pub fn deploy_on_push() -> Workflow {
+ Workflow::new("Deploy on Push")
+ .on(Event::default().push(Push::default().add_branch("main")))
+ .concurrency(
+ // Never cancel an in-progress deployment — that could leave a
+ // stack half-applied. Queued pushes coalesce to the newest.
+ Concurrency::new(Expression::new("${{ github.workflow }}")).cancel_in_progress(false),
+ )
+ .add_job("check-to-deploy", check_to_deploy())
+ .add_job("deploy-cloud-storage", deploy_cloud_storage())
+ .add_job("deploy-sync-service", deploy_sync_service())
+ .add_job("deploy-web-app", deploy_web_app())
+}
+
+/// Add the caller jobs' `with:` and explicit `secrets:` maps, and drop the
+/// `runs-on` that `Job::default()` injects (invalid alongside `uses:`).
+pub fn patch(root: &mut serde_yaml::Value) -> Result<()> {
+ let cloud_storage = crate::workflows::job_mut(root, "deploy-cloud-storage")?;
+ cloud_storage.remove("runs-on");
+ cloud_storage.insert(
+ "with".into(),
+ crate::workflows::yaml_fragment("environment: dev")?,
+ );
+ cloud_storage.insert(
+ "secrets".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
+ DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
+ DD_API_KEY: ${{ secrets.DD_API_KEY }}
+ NIX_CACHE_SIGNING_KEY: ${{ secrets.NIX_CACHE_SIGNING_KEY }}
+ "#})?,
+ );
+
+ let sync_service = crate::workflows::job_mut(root, "deploy-sync-service")?;
+ sync_service.remove("runs-on");
+ sync_service.insert(
+ "with".into(),
+ crate::workflows::yaml_fragment("environment: dev")?,
+ );
+ sync_service.insert(
+ "secrets".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ "#})?,
+ );
+
+ let web_app = crate::workflows::job_mut(root, "deploy-web-app")?;
+ web_app.remove("runs-on");
+ web_app.insert(
+ "with".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ notify: false
+ environment: dev
+ "#})?,
+ );
+ web_app.insert(
+ "secrets".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+ PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
+ DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
+ DD_API_KEY: ${{ secrets.DD_API_KEY }}
+ SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}
+ POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
+ "#})?,
+ );
+ Ok(())
+}
+
+fn check_to_deploy() -> Job {
+ Job::default()
+ .runs_on(runners::Runner::TinyNoCache.to_string())
+ .add_output(
+ "cloud-storage",
+ "${{ steps.changes.outputs.cloud-storage }}",
+ )
+ .add_output("sync-service", "${{ steps.changes.outputs.sync-service }}")
+ .add_output("web-app", "${{ steps.changes.outputs.web-app }}")
+ .add_step(checkout())
+ .add_step(diff_checker())
+}
+
+fn deploy_cloud_storage() -> Job {
+ Job::default()
+ .name("Deploy Cloud Storage Services")
+ .needs(vec!["check-to-deploy".to_string()])
+ .cond(Expression::new(
+ "${{ needs.check-to-deploy.outputs.cloud-storage == 'true' }}",
+ ))
+ .uses("./.github/workflows/deploy_all_services.yml")
+}
+
+/// The worker calls DSS/SPS, so don't ship it ahead of them (same ordering as
+/// the production release) — but do ship it when the cloud-storage stage was
+/// *skipped* for having no changes, hence `!failure()` instead of the implicit
+/// `success()`.
+fn deploy_sync_service() -> Job {
+ Job::default()
+ .name("Deploy Sync Service")
+ .needs(vec![
+ "check-to-deploy".to_string(),
+ "deploy-cloud-storage".to_string(),
+ ])
+ .cond(Expression::new(
+ "${{ !failure() && !cancelled() && needs.check-to-deploy.outputs.sync-service == 'true' }}",
+ ))
+ .uses("./.github/workflows/deploy_sync_service.yml")
+}
+
+/// Same skipped-backend tolerance as [`deploy_sync_service`].
+fn deploy_web_app() -> Job {
+ Job::default()
+ .name("Deploy Web App")
+ .needs(vec![
+ "check-to-deploy".to_string(),
+ "deploy-cloud-storage".to_string(),
+ ])
+ .cond(Expression::new(
+ "${{ !failure() && !cancelled() && needs.check-to-deploy.outputs.web-app == 'true' }}",
+ ))
+ .uses("./.github/workflows/deploy_web_app.yml")
+}
+
+fn checkout() -> Step<Use> {
+ Step::new("Checkout Repo").uses(
+ "actions",
+ "checkout",
+ "df4cb1c069e1874edd31b4311f1884172cec0e10",
+ ) // v6
+}
+
+fn diff_checker() -> Step<Use> {
+ let diff = [
+ diff_entry("cloud-storage", CLOUD_STORAGE_PATHS),
+ diff_entry("sync-service", SYNC_SERVICE_PATHS),
+ format!(
+ "web-app: ./infra/stacks/web-app/** ./.github/workflows/deploy_on_push.yml ./.github/workflows/deploy_web_app.yml {}",
+ web_artifact_paths::diff_checker_list()
+ ),
+ ]
+ .join("\n");
+
+ Step::new("Check changed paths")
+ .uses(
+ "whutchinson98",
+ "diff-checker-action",
+ "d25a22ee8f84f5e44abda3027c80c2e6d71f68a6",
+ ) // v1.0.2
+ .id("changes")
+ .add_with(("token", "${{ github.token }}"))
+ .add_with(("diff", diff))
+}
+
+/// Render one diff-checker group line (`<group>: ./a ./b/** …`).
+fn diff_entry(group: &str, paths: &[RepoGlob<'static>]) -> String {
+ let list = paths
+ .iter()
+ .map(|path| format!("./{}", path.as_str()))
+ .collect::<Vec<_>>()
+ .join(" ");
+ format!("{group}: {list}")
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs
index caa26568a6..2ace636ef7 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_sync_service.rs
@@ -1,11 +1,15 @@
//! `Deploy Sync Service` — deploys the `sync_service` Cloudflare Worker
//! (`services/sync-service`) via wrangler, applying its D1 migrations first.
//! Unlike [`crate::workflows::deploy_ai_editing_worker`] this worker is Rust, so
-//! the job needs a toolchain and the wasm target. Generated into
-//! `deploy_sync_service.yml`.
+//! the job needs a toolchain and the wasm target. Call/dispatch-only: push
+//! deploys to dev come through [`crate::workflows::deploy_on_push`] (which owns
+//! the path gating) and prod deploys through `release-production`. Generated
+//! into `deploy_sync_service.yml`.
use anyhow::Result;
-use gh_workflow::{Concurrency, Event, Expression, Job, Push, Run, Step, Use, Workflow};
+use gh_workflow::{
+ Concurrency, Event, Expression, Job, Run, Step, Use, Workflow, WorkflowCall, WorkflowDispatch,
+};
use crate::workflows::{runners, steps, vars};
@@ -13,23 +17,11 @@ const ENVIRONMENT: &str = "${{ inputs.environment || 'dev' }}";
pub fn deploy_sync_service() -> Workflow {
Workflow::new("Deploy Sync Service")
- .on(Event::default()
- // Only redeploy when the worker, its one path dependency, or the
- // workspace's Rust pinning changes.
- .push(
- Push::default()
- .add_branch("main")
- .add_path(xtask_paths::repo_glob!(
- ".github/workflows/deploy_sync_service.yml"
- ))
- .add_path(xtask_paths::repo_glob!("services/sync-service/**"))
- .add_path(xtask_paths::repo_glob!("crates/macro_sync_service_jwt/**"))
- .add_path(xtask_paths::repo_glob!("Cargo.toml"))
- .add_path(xtask_paths::repo_glob!("Cargo.lock"))
- .add_path(xtask_paths::repo_glob!("rust-toolchain.toml")),
- ))
// The `workflow_call` / `workflow_dispatch` input blocks are filled in
// by `patch` below.
+ .on(Event::default()
+ .workflow_dispatch(WorkflowDispatch::default())
+ .workflow_call(WorkflowCall::default()))
.concurrency(
// Literal prefix rather than `github.workflow`: for workflow_call
// runs that expression expands to the *caller's* name.
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app_dev_push.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app_dev_push.rs
deleted file mode 100644
index 1f34f88e63..0000000000
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app_dev_push.rs
+++ /dev/null
@@ -1,92 +0,0 @@
-//! `Deploy web app dev on push to main` — path-gated caller of
-//! [`crate::workflows::deploy_web_app`]. Generated into
-//! `deploy_web_app_dev_push.yml` (replaces the hand-written
-//! `deploy-web-app-dev-push.yml`).
-
-use anyhow::Result;
-use gh_workflow::{Concurrency, Event, Expression, Job, Push, Step, Use, Workflow};
-
-use crate::workflows::{runners, web_artifact_paths};
-
-/// Build the workflow. The caller job's `with:`/`secrets:` are filled in by
-/// [`patch`].
-pub fn deploy_web_app_dev_push() -> Workflow {
- Workflow::new("Deploy web app dev on push to main")
- .on(Event::default().push(Push::default().add_branch("main")))
- .concurrency(
- // Never cancel an in-progress deployment — that could leave the
- // stack half-applied.
- Concurrency::new(Expression::new("${{ github.workflow }}")).cancel_in_progress(false),
- )
- .add_job("check-to-deploy", check_to_deploy())
- .add_job("deploy_web_app", deploy_web_app())
-}
-
-/// Add the caller job's `with:` and explicit `secrets:` map, and drop the
-/// `runs-on` that `Job::default()` injects (invalid alongside `uses:`).
-pub fn patch(root: &mut serde_yaml::Value) -> Result<()> {
- let job = crate::workflows::job_mut(root, "deploy_web_app")?;
- job.remove("runs-on");
- job.insert(
- "with".into(),
- crate::workflows::yaml_fragment(indoc::indoc! {r#"
- notify: false
- environment: dev
- "#})?,
- );
- job.insert(
- "secrets".into(),
- crate::workflows::yaml_fragment(indoc::indoc! {r#"
- AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- DD_APP_KEY: ${{ secrets.DD_APP_KEY }}
- DD_API_KEY: ${{ secrets.DD_API_KEY }}
- SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_PRODUCTION }}
- POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
- "#})?,
- );
- Ok(())
-}
-
-fn check_to_deploy() -> Job {
- Job::default()
- .runs_on(runners::Runner::TinyNoCache.to_string())
- .add_output("web-app", "${{ steps.changes.outputs.web-app }}")
- .add_step(checkout())
- .add_step(diff_checker())
-}
-
-fn deploy_web_app() -> Job {
- Job::default()
- .needs(vec!["check-to-deploy".to_string()])
- .cond(Expression::new(
- "${{ needs.check-to-deploy.outputs.web-app == 'true' }}",
- ))
- .uses("./.github/workflows/deploy_web_app.yml")
-}
-
-fn checkout() -> Step<Use> {
- Step::new("Checkout Repo").uses(
- "actions",
- "checkout",
- "df4cb1c069e1874edd31b4311f1884172cec0e10",
- ) // v6
-}
-
-fn diff_checker() -> Step<Use> {
- let web_app_paths = web_artifact_paths::diff_checker_list();
-
- Step::new("Check changed paths")
- .uses(
- "whutchinson98",
- "diff-checker-action",
- "d25a22ee8f84f5e44abda3027c80c2e6d71f68a6",
- ) // v1.0.2
- .id("changes")
- .add_with(("token", "${{ github.token }}"))
- .add_with((
- "diff",
- format!("web-app: ./infra/stacks/web-app/** {web_app_paths}"),
- ))
-}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
index 67b279235e..d846ea4469 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
@@ -25,12 +25,11 @@ mod code_check_conventions;
mod code_check_infra;
mod deploy_ai_editing_worker;
mod deploy_all_services;
-mod deploy_cloud_storage_on_push;
mod deploy_fusionauth_instance;
+mod deploy_on_push;
mod deploy_preview;
mod deploy_sync_service;
mod deploy_web_app;
-mod deploy_web_app_dev_push;
mod path_validation;
mod preview_fly;
mod pulumi_preview_pr;
@@ -180,14 +179,9 @@ const WORKFLOWS: &[WorkflowFile] = &[
},
},
WorkflowFile {
- slug: "deploy_cloud_storage_on_push",
- file_name: "deploy_cloud_storage_on_push.yml",
- render_yaml: || {
- render_patched(
- deploy_cloud_storage_on_push::deploy_cloud_storage_on_push,
- deploy_cloud_storage_on_push::patch,
- )
- },
+ slug: "deploy_on_push",
+ file_name: "deploy_on_push.yml",
+ render_yaml: || render_patched(deploy_on_push::deploy_on_push, deploy_on_push::patch),
},
WorkflowFile {
slug: "deploy_fusionauth_instance",
@@ -219,16 +213,6 @@ const WORKFLOWS: &[WorkflowFile] = &[
file_name: "deploy_web_app.yml",
render_yaml: || render_patched(deploy_web_app::deploy_web_app, deploy_web_app::patch),
},
- WorkflowFile {
- slug: "deploy_web_app_dev_push",
- file_name: "deploy_web_app_dev_push.yml",
- render_yaml: || {
- render_patched(
- deploy_web_app_dev_push::deploy_web_app_dev_push,
- deploy_web_app_dev_push::patch,
- )
- },
- },
WorkflowFile {
slug: "pulumi_preview_pr",
file_name: "pulumi_preview_pr.yml",