← Back to ClawMarket

OpenClaw Deployment Workflow

A multi-step deployment workflow for OpenClaw that handles build, test, staging verification, and production release with rollback support.

Workflowautomationopenclawdeploymentci-cdrollback

by Build Ship Grow

openclaw-deployment-workflow.yml
yaml
# OpenClaw Deployment Workflow
# Multi-stage deploy with health checks and automatic rollback

workflow:
  name: deploy-to-production
  runtime: openclaw/v1
  description: Build, test, stage, and deploy with rollback safety net
  trigger:
    event: push
    branch: main

env:
  REGISTRY: ghcr.io/${{ org }}/${{ repo }}
  DEPLOY_TIMEOUT: 300

stages:
  - name: build
    agent: openclaw/builder
    steps:
      - run: bun install --frozen-lockfile
      - run: bun run lint
      - run: bun run build
      - run: docker build -t ${{ env.REGISTRY }}:${{ git.sha }} .
      - run: docker push ${{ env.REGISTRY }}:${{ git.sha }}
    on_failure:
      - notify:
          channel: slack
          message: "Build failed for ${{ git.sha_short }} — ${{ error.message }}"

  - name: test
    agent: openclaw/runner
    depends_on: [build]
    steps:
      - run: bun run test
      - run: bun run test:e2e
    timeout: 180
    on_failure:
      - notify:
          channel: slack
          message: "Tests failed — blocking deploy"

  - name: staging
    agent: openclaw/deployer
    depends_on: [test]
    steps:
      - deploy:
          target: staging
          image: ${{ env.REGISTRY }}:${{ git.sha }}
          replicas: 1
      - health_check:
          url: https://staging.example.com/api/health
          retries: 5
          interval: 10
      - run: bun run test:smoke --env staging
    on_failure:
      - rollback:
          target: staging
      - notify:
          channel: slack
          message: "Staging verification failed — rolled back"

  - name: production
    agent: openclaw/deployer
    depends_on: [staging]
    approval:
      required: true
      approvers: ["team-leads"]
      timeout: 3600
    steps:
      - deploy:
          target: production
          image: ${{ env.REGISTRY }}:${{ git.sha }}
          strategy: rolling
          replicas: 3
          max_surge: 1
      - health_check:
          url: https://app.example.com/api/health
          retries: 10
          interval: 15
    on_failure:
      - rollback:
          target: production
      - notify:
          channel: slack
          message: "Production deploy failed — automatic rollback triggered"
    on_success:
      - notify:
          channel: slack
          message: "Deployed ${{ git.sha_short }} to production"