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): add fusionauth instance deploy workflow (#5253)

Will Hutchinson76e428b79328
diff --git a/.github/workflows/deploy_fusionauth_instance.yml b/.github/workflows/deploy_fusionauth_instance.yml
new file mode 100644
index 0000000000..7dc69dcfe2
--- /dev/null
+++ b/.github/workflows/deploy_fusionauth_instance.yml
@@ -0,0 +1,27 @@
+# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).
+# Source: tooling/xtask/crates/xtask_workflows/src/workflows/deploy_fusionauth_instance.rs
+name: Deploy FusionAuth Instance
+on:
+ workflow_dispatch:
+ inputs:
+ environment:
+ type: choice
+ required: true
+ default: dev
+ options:
+ - dev
+ - prod
+ description: The environment to deploy to.
+jobs:
+ deploy:
+ name: Deploy fusionauth-instance
+ uses: ./.github/workflows/reusable_deploy_service.yml
+ with:
+ environment: ${{ inputs.environment }}
+ service-name: fusionauth-instance
+ pulumi-stack-name: fusionauth-instance
+ use-docker: false
+ secrets: inherit
+concurrency:
+ group: deploy-fusionauth-instance-${{ inputs.environment }}
+ cancel-in-progress: false
diff --git a/.github/workflows/reusable_deploy_service.yml b/.github/workflows/reusable_deploy_service.yml
index 9f8eb67c50..c10cca9ad6 100644
--- a/.github/workflows/reusable_deploy_service.yml
+++ b/.github/workflows/reusable_deploy_service.yml
@@ -178,6 +178,7 @@ jobs:
persist-credentials: 'false'
- id: project-name
name: Get project name
+ if: ${{ inputs.pulumi-stack-name == '' }}
uses: ./.github/actions/get-project-name
with:
service-name: ${{ inputs.service-name }}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_fusionauth_instance.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_fusionauth_instance.rs
new file mode 100644
index 0000000000..d9922b3d05
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_fusionauth_instance.rs
@@ -0,0 +1,62 @@
+//! `Deploy FusionAuth Instance` — manually deploys the FusionAuth instance
+//! configuration Pulumi stack to dev or prod through the shared single-service
+//! deployment workflow. Generated into `deploy_fusionauth_instance.yml`.
+
+use anyhow::Result;
+use gh_workflow::{Concurrency, Event, Expression, Job, Workflow, WorkflowDispatch};
+
+/// Build the workflow. The dispatch input and reusable-workflow caller fields
+/// are filled in by [`patch`].
+pub fn deploy_fusionauth_instance() -> Workflow {
+ Workflow::new("Deploy FusionAuth Instance")
+ .on(Event::default().workflow_dispatch(WorkflowDispatch::default()))
+ .concurrency(
+ Concurrency::new(Expression::new(
+ "deploy-fusionauth-instance-${{ inputs.environment }}",
+ ))
+ .cancel_in_progress(false),
+ )
+ .add_job("deploy", deploy())
+}
+
+/// Fill in the ordered dispatch input and reusable-workflow caller fields.
+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_dispatch".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ inputs:
+ environment:
+ type: choice
+ required: true
+ default: dev
+ options:
+ - dev
+ - prod
+ description: The environment to deploy to.
+ "#})?,
+ );
+
+ let job = crate::workflows::job_mut(root, "deploy")?;
+ job.remove("runs-on");
+ job.insert(
+ "with".into(),
+ crate::workflows::yaml_fragment(indoc::indoc! {r#"
+ environment: ${{ inputs.environment }}
+ service-name: fusionauth-instance
+ pulumi-stack-name: fusionauth-instance
+ use-docker: false
+ "#})?,
+ );
+ job.insert("secrets".into(), "inherit".into());
+ Ok(())
+}
+
+fn deploy() -> Job {
+ Job::default()
+ .name("Deploy fusionauth-instance")
+ .uses("./.github/workflows/reusable_deploy_service.yml")
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
index baedc155f6..41c01a4b56 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/mod.rs
@@ -26,6 +26,7 @@ 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_preview;
mod deploy_web_app;
mod deploy_web_app_dev_push;
@@ -186,6 +187,16 @@ const WORKFLOWS: &[WorkflowFile] = &[
)
},
},
+ WorkflowFile {
+ slug: "deploy_fusionauth_instance",
+ file_name: "deploy_fusionauth_instance.yml",
+ render_yaml: || {
+ render_patched(
+ deploy_fusionauth_instance::deploy_fusionauth_instance,
+ deploy_fusionauth_instance::patch,
+ )
+ },
+ },
WorkflowFile {
slug: "deploy_preview",
file_name: "deploy_preview.yml",
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/reusable_deploy_service.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/reusable_deploy_service.rs
index 518e0f1625..ce39cf2172 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/reusable_deploy_service.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/reusable_deploy_service.rs
@@ -214,6 +214,7 @@ fn get_project_name() -> Step<Use> {
xtask_paths::repo_dir!(".github/actions/get-project-name"),
)
.id("project-name")
+ .if_condition(Expression::new("${{ inputs.pulumi-stack-name == '' }}"))
.add_with(("service-name", "${{ inputs.service-name }}"))
}