Deploy Staging #61
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Staging | |
| permissions: | |
| contents: read | |
| deployments: write | |
| id-token: write | |
| security-events: write # Required for Trivy SARIF upload in test workflow | |
| concurrency: | |
| group: robosystems-app-deploy | |
| cancel-in-progress: false | |
| on: | |
| workflow_dispatch: | |
| workflow_call: | |
| jobs: | |
| runner: | |
| if: vars.ENVIRONMENT_STAGING_ENABLED == 'true' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| runners_available: ${{ steps.check.outputs.runners_available }} | |
| runner_type: ${{ steps.check.outputs.runner_type }} | |
| runner_config: ${{ steps.check.outputs.runner_config }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.repository }} | |
| ref: ${{ github.ref }} | |
| token: ${{ github.token }} | |
| - name: Check runner availability | |
| id: check | |
| uses: ./.github/actions/runner-availability | |
| with: | |
| runner_labels: ${{ vars.RUNNER_LABELS || 'github-hosted' }} | |
| runner_scope: ${{ vars.RUNNER_SCOPE || 'both' }} | |
| github_token: ${{ github.token }} | |
| test: | |
| needs: [runner] | |
| uses: ./.github/workflows/test.yml | |
| with: | |
| runner_config: ${{ needs.runner.outputs.runner_config }} | |
| secrets: inherit | |
| create-deployment: | |
| needs: [runner, test] | |
| runs-on: ${{ fromJSON(needs.runner.outputs.runner_config) }} | |
| outputs: | |
| deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
| steps: | |
| - name: Create GitHub Deployment | |
| id: deployment | |
| uses: chrnorm/deployment-action@v2 | |
| with: | |
| token: ${{ github.token }} | |
| environment: staging | |
| description: 'Staging Deployment Created' | |
| - name: Update Deployment Status | |
| uses: chrnorm/deployment-status@v2 | |
| with: | |
| token: ${{ github.token }} | |
| state: in_progress | |
| deployment-id: ${{ steps.deployment.outputs.deployment_id }} | |
| description: 'Staging Deployment In Progress' | |
| deploy-s3: | |
| needs: [runner, test, create-deployment] | |
| uses: ./.github/workflows/deploy-s3.yml | |
| with: | |
| runner_config: ${{ needs.runner.outputs.runner_config }} | |
| stack_name: RoboSystemsAppS3Staging | |
| environment: ${{ vars.ENVIRONMENT_STAGING || 'staging' }} | |
| aws_account_id: ${{ vars.AWS_ACCOUNT_ID }} | |
| aws_region: ${{ vars.AWS_REGION || 'us-east-1' }} | |
| namespace: ${{ vars.AWS_ACCOUNT_ID }} | |
| secrets: inherit | |
| build: | |
| needs: [runner, test, deploy-s3] | |
| uses: ./.github/workflows/build.yml | |
| with: | |
| runner_config: ${{ needs.runner.outputs.runner_config }} | |
| environment: ${{ vars.ENVIRONMENT_STAGING || 'staging' }} | |
| region: ${{ vars.AWS_REGION || 'us-east-1' }} | |
| robosystems_api_url: ${{ vars.ROBOSYSTEMS_API_URL_STAGING || 'https://staging.api.robosystems.ai' }} | |
| roboledger_app_url: ${{ vars.ROBOLEDGER_APP_URL_STAGING || 'https://staging.roboledger.ai' }} | |
| roboinvestor_app_url: ${{ vars.ROBOINVESTOR_APP_URL_STAGING || 'https://staging.roboinvestor.ai' }} | |
| robosystems_app_url: ${{ vars.ROBOSYSTEMS_APP_URL_STAGING || 'https://staging.robosystems.ai' }} | |
| maintenance_mode: ${{ vars.MAINTENANCE_MODE_STAGING || 'false' }} | |
| turnstile_site_key: ${{ vars.TURNSTILE_SITE_KEY || '' }} | |
| static_assets_bucket_name: ${{ needs.deploy-s3.outputs.static_assets_bucket_name }} | |
| # Docker Hub publishing for staging: disabled (staging builds should not go to Docker Hub) | |
| publish_to_dockerhub: false | |
| secrets: inherit | |
| deploy-app: | |
| needs: [runner, create-deployment, deploy-s3, build] | |
| uses: ./.github/workflows/deploy-app.yml | |
| with: | |
| # GHA Runner Configuration | |
| runner_config: ${{ needs.runner.outputs.runner_config }} | |
| # Environment & AWS Configuration | |
| environment: ${{ vars.ENVIRONMENT_STAGING || 'staging' }} | |
| aws_account_id: ${{ vars.AWS_ACCOUNT_ID }} | |
| aws_region: ${{ vars.AWS_REGION || 'us-east-1' }} | |
| stack_name: RoboSystemsAppStaging | |
| # Access Mode Configuration | |
| app_access_mode: ${{ vars.APP_ACCESS_MODE_STAGING || 'public' }} | |
| # S3 Bucket Configuration (from deploy-s3 outputs) | |
| static_assets_bucket_name: ${{ needs.deploy-s3.outputs.static_assets_bucket_name }} | |
| static_assets_bucket_arn: ${{ needs.deploy-s3.outputs.static_assets_bucket_arn }} | |
| static_assets_bucket_domain: ${{ needs.deploy-s3.outputs.static_assets_bucket_domain }} | |
| # Container & Application Configuration | |
| ecr_repository: ${{ vars.ECR_REPOSITORY || 'robosystems-app' }} | |
| ecr_image_tag: ${{ needs.build.outputs.image_tag }} | |
| # App Runner Compute Configuration | |
| cpu: ${{ vars.CPU_STAGING || '0.25 vCPU' }} | |
| memory: ${{ vars.MEMORY_STAGING || '0.5 GB' }} | |
| # Auto-scaling Configuration | |
| capacity_min: ${{ vars.CAPACITY_MIN_STAGING || '1' }} | |
| capacity_max: ${{ vars.CAPACITY_MAX_STAGING || '2' }} | |
| max_concurrency: ${{ vars.MAX_CONCURRENCY_STAGING || '100' }} | |
| # Domain & DNS Configuration (required for public mode) | |
| domain_name: ${{ vars.DOMAIN_NAME_STAGING || 'staging.robosystems.ai' }} | |
| domain_name_root: ${{ vars.DOMAIN_NAME_ROOT || 'robosystems.ai' }} | |
| # SNS Configuration | |
| notification_email: ${{ vars.AWS_SNS_ALERT_EMAIL || '' }} | |
| secrets: inherit | |
| deployment-successful: | |
| needs: [runner, create-deployment, build, deploy-app] | |
| runs-on: ${{ fromJSON(needs.runner.outputs.runner_config) }} | |
| outputs: | |
| deployment_id: ${{ needs.create-deployment.outputs.deployment_id }} | |
| steps: | |
| - name: Update Deployment Status | |
| uses: chrnorm/deployment-status@v2 | |
| with: | |
| token: ${{ github.token }} | |
| state: success | |
| deployment-id: ${{ needs.create-deployment.outputs.deployment_id }} | |
| description: 'Staging Deployment Succeeded' | |
| handle-deployment-failure: | |
| needs: [runner, create-deployment, build, deploy-app] | |
| if: always() && contains(needs.*.result, 'failure') | |
| runs-on: ${{ fromJSON(needs.runner.outputs.runner_config) }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.repository }} | |
| ref: ${{ github.ref }} | |
| token: ${{ github.token }} | |
| - name: Handle Deployment Failure | |
| uses: ./.github/actions/handle-deployment-failure | |
| with: | |
| deployment-id: ${{ needs.create-deployment.outputs.deployment_id }} | |
| environment: staging | |
| github-token: ${{ github.token }} |