Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(ci): migrate cleanup-preview to namespace + cargo x workflows (#4510)
teo85fad3c83ce7
diff --git a/.github/workflows/cleanup-preview.yml b/.github/workflows/cleanup-preview.ymldeleted file mode 100644index b8b8d18643..0000000000--- a/.github/workflows/cleanup-preview.yml+++ /dev/null@@ -1,51 +0,0 @@-# Cleanup Preview Deployment-#-# Removes preview files from S3 when PR is closed--name: Cleanup Preview--on:- pull_request:- types: [closed]--env:- PREVIEW_BUCKET: macro-preview-assets-dev--jobs:- cleanup:- runs-on: ubuntu-latest- permissions:- contents: read- pull-requests: read- steps:- - uses: actions/checkout@v6-- - name: Setup Bun- uses: oven-sh/setup-bun@v2-- - name: Configure AWS Credentials- uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b- with:- aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}- aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}- aws-region: us-east-1-- - name: Get preview ID from comments- id: preview-id- working-directory: js/app- run: |- PREVIEW_ID=$(bun scripts/preview/get-or-create-id.ts \- --pr ${{ github.event.pull_request.number }} \- --repo ${{ github.repository }} \- --token ${{ secrets.GITHUB_TOKEN }} \- --branch "${{ github.head_ref }}")- echo "id=$PREVIEW_ID" >> $GITHUB_OUTPUT- echo "Preview ID: $PREVIEW_ID"-- - name: Cleanup preview- if: steps.preview-id.outputs.id != ''- working-directory: js/app- run: |- bun scripts/preview/deploy.ts \- --preview-id ${{ steps.preview-id.outputs.id }} \- --cleanupdiff --git a/.github/workflows/cleanup_preview.yml b/.github/workflows/cleanup_preview.ymlnew file mode 100644index 0000000000..dadb322bf0--- /dev/null+++ b/.github/workflows/cleanup_preview.yml@@ -0,0 +1,46 @@+# DO NOT EDIT — regenerate with `cargo x workflows` (from rust/cloud-storage).+# Source: rust/cloud-storage/tools/xtask/src/workflows/cleanup_preview.rs+name: Cleanup Preview+env:+ PREVIEW_BUCKET: macro-preview-assets-dev+'on':+ pull_request:+ types:+ - closed+jobs:+ cleanup:+ runs-on: namespace-profile-linux-tiny-no-cache+ permissions:+ contents: read+ pull-requests: read+ steps:+ - name: Checkout Repo+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10+ - name: Setup Bun+ uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6+ - name: Configure AWS Credentials+ uses: aws-actions/configure-aws-credentials@e7f100cf4c008499ea8adda475de1042d6975c7b+ with:+ aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}+ aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}+ aws-region: us-east-1+ - id: preview-id+ name: Get preview ID from comments+ run: |+ PREVIEW_ID=$(bun scripts/preview/get-or-create-id.ts \+ --pr ${{ github.event.pull_request.number }} \+ --repo ${{ github.repository }} \+ --token ${{ secrets.GITHUB_TOKEN }} \+ --branch "$BRANCH")+ echo "id=$PREVIEW_ID" >> $GITHUB_OUTPUT+ echo "Preview ID: $PREVIEW_ID"+ env:+ BRANCH: ${{ github.head_ref }}+ working-directory: js/app+ - name: Cleanup preview+ if: steps.preview-id.outputs.id != ''+ run: |+ bun scripts/preview/deploy.ts \+ --preview-id ${{ steps.preview-id.outputs.id }} \+ --cleanup+ working-directory: js/appdiff --git a/rust/cloud-storage/tools/xtask/src/workflows/cleanup_preview.rs b/rust/cloud-storage/tools/xtask/src/workflows/cleanup_preview.rsnew file mode 100644index 0000000000..51e278b593--- /dev/null+++ b/rust/cloud-storage/tools/xtask/src/workflows/cleanup_preview.rs@@ -0,0 +1,92 @@+//! `Cleanup Preview` — removes a PR's preview files from S3 when the PR+//! closes (companion to `deploy_preview`). Generated into+//! `cleanup_preview.yml` (replaces the hand-written `cleanup-preview.yml`).++use gh_workflow::{+ Env, Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType, Run, Step, Use,+ Workflow,+};++use crate::workflows::{runners, vars};++const PREVIEW_BUCKET: &str = "macro-preview-assets-dev";++/// Build the workflow.+pub fn cleanup_preview() -> Workflow {+ Workflow::new("Cleanup Preview")+ .on(Event::default().pull_request(PullRequest::default().add_type(PullRequestType::Closed)))+ .add_env(("PREVIEW_BUCKET", PREVIEW_BUCKET))+ .add_job("cleanup", cleanup())+}++fn cleanup() -> Job {+ Job::default()+ .runs_on(runners::Runner::TinyNoCache.to_string())+ .permissions(+ Permissions::default()+ .contents(Level::Read)+ .pull_requests(Level::Read),+ )+ .add_step(checkout())+ .add_step(setup_bun())+ .add_step(configure_aws_credentials())+ .add_step(get_preview_id())+ .add_step(cleanup_preview_files())+}++fn checkout() -> Step<Use> {+ Step::new("Checkout Repo").uses(+ "actions",+ "checkout",+ "df4cb1c069e1874edd31b4311f1884172cec0e10",+ ) // v6+}++fn setup_bun() -> Step<Use> {+ Step::new("Setup Bun").uses(+ "oven-sh",+ "setup-bun",+ "0c5077e51419868618aeaa5fe8019c62421857d6",+ ) // v2+}++fn configure_aws_credentials() -> Step<Use> {+ Step::new("Configure AWS Credentials")+ .uses(+ "aws-actions",+ "configure-aws-credentials",+ "e7f100cf4c008499ea8adda475de1042d6975c7b",+ ) // v5+ .add_with(("aws-access-key-id", vars::AWS_ACCESS_KEY))+ .add_with(("aws-secret-access-key", vars::AWS_SECRET_ACCESS_KEY))+ .add_with(("aws-region", "us-east-1"))+}++/// The branch name is attacker-controlled, so it reaches the script via env+/// (an env expansion can never become script text) instead of being inlined.+fn get_preview_id() -> Step<Run> {+ Step::new("Get preview ID from comments")+ .run(indoc::indoc! {r#"+ PREVIEW_ID=$(bun scripts/preview/get-or-create-id.ts \+ --pr ${{ github.event.pull_request.number }} \+ --repo ${{ github.repository }} \+ --token ${{ secrets.GITHUB_TOKEN }} \+ --branch "$BRANCH")+ echo "id=$PREVIEW_ID" >> $GITHUB_OUTPUT+ echo "Preview ID: $PREVIEW_ID"+ "#})+ .id("preview-id")+ .working_directory("js/app")+ .add_env(Env::new("BRANCH", "${{ github.head_ref }}"))+}++fn cleanup_preview_files() -> Step<Run> {+ Step::new("Cleanup preview")+ .run(indoc::indoc! {r#"+ bun scripts/preview/deploy.ts \+ --preview-id ${{ steps.preview-id.outputs.id }} \+ --cleanup+ "#})+ .if_condition(Expression::new("steps.preview-id.outputs.id != ''"))+ .working_directory("js/app")+}diff --git a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs b/rust/cloud-storage/tools/xtask/src/workflows/mod.rsindex 4a116d16a4..bd3d6304c0 100644--- a/rust/cloud-storage/tools/xtask/src/workflows/mod.rs+++ b/rust/cloud-storage/tools/xtask/src/workflows/mod.rs@@ -16,6 +16,7 @@ mod build_desktop_on_tag;mod build_dmg_on_tag;mod check_generated;mod check_node_modules_nix;+mod cleanup_preview;mod code_check_cloud_storage;mod code_check_infra;mod deploy_preview;@@ -110,6 +111,11 @@ const WORKFLOWS: &[WorkflowFile] = &[file_name: "code_check_infra.yml",render_yaml: || render_gh_workflow(code_check_infra::code_check_infra)(),},+ WorkflowFile {+ slug: "cleanup_preview",+ file_name: "cleanup_preview.yml",+ render_yaml: || render_gh_workflow(cleanup_preview::cleanup_preview)(),+ },WorkflowFile {slug: "code_check_cloud_storage",file_name: "code_check_cloud_storage.yml",