name: deploy
description: Deploy application with safety checks

triggers:
  keywords:
    - "deploy"
    - "ship it"
    - "release"

inputs:
  version:
    type: string
    required: true
    pattern: '^v\d+\.\d+\.\d+$'
    description: "Version to deploy (e.g., v1.2.3)"

  environment:
    type: string
    required: true
    enum: [staging, production]
    default: staging
    description: "Target environment"

steps:
  - id: test
    type: script
    description: Run test suite
    run: echo "Running tests..." && echo "All tests passed"
    validation:
      exit_code: 0

  - id: build
    type: script
    description: Build application
    run: echo "Building for {{inputs.environment}}..." && echo "Build complete"
    needs: [test]
    validation:
      exit_code: 0

  - id: deploy-staging
    type: script
    description: Deploy to staging
    run: echo "Deploying {{inputs.version}} to staging..." && echo "Staging deploy complete"
    needs: [build]
    validation:
      exit_code: 0

  - id: approve
    type: approval
    description: Approve production deployment
    when: inputs.environment == "production"
    prompt: |
      Ready to deploy {{inputs.version}} to production.
      
      Staging deployment was successful.
      
      Proceed with production deployment?
    needs: [deploy-staging]

  - id: deploy-prod
    type: script
    description: Deploy to production
    when: inputs.environment == "production"
    run: echo "Deploying {{inputs.version}} to production..." && echo "Production deploy complete"
    needs: [approve]
    validation:
      exit_code: 0

settings:
  timeout: 30m
  enforcement: strict
  on_failure: stop
