diff --git a/.github/workflows/_deploy-container.yml b/.github/workflows/_deploy-container.yml index 52110ec673..d71099c01b 100644 --- a/.github/workflows/_deploy-container.yml +++ b/.github/workflows/_deploy-container.yml @@ -38,7 +38,7 @@ jobs: deploy: name: Deploy runs-on: ubuntu-24.04 - environment: ${{ inputs.azure_environment == 'prod' && 'production' || 'staging' }} + environment: ${{ github.event_name != 'pull_request' && (inputs.azure_environment == 'prod' && 'production' || 'staging') || '' }} env: UNIQUE_PREFIX: ${{ vars.UNIQUE_PREFIX }} ENVIRONMENT: ${{ inputs.azure_environment }} diff --git a/.github/workflows/_deploy-infrastructure.yml b/.github/workflows/_deploy-infrastructure.yml index 9ec3b0f75f..ea56acaf75 100644 --- a/.github/workflows/_deploy-infrastructure.yml +++ b/.github/workflows/_deploy-infrastructure.yml @@ -42,7 +42,20 @@ jobs: plan: name: Plan runs-on: ubuntu-24.04 + outputs: + should_deploy: ${{ steps.determine_deployment.outputs.should_deploy }} steps: + - name: Determine Deployment Conditions # For production: only deploy from main branch, but for staging also deploy from pull requests with 'Deploy to Staging' label + id: determine_deployment + run: | + if [[ "${{ inputs.azure_environment }}" == "prod" && "${{ github.ref }}" == "refs/heads/main" ]]; then + should_deploy="true" + elif [[ "${{ inputs.azure_environment }}" == "stage" && ("${{ github.ref }}" == "refs/heads/main" || "${{ contains(github.event.pull_request.labels.*.name, 'Deploy to Staging') }}" == "true") ]]; then + should_deploy="true" + else + should_deploy="false" + fi + echo "should_deploy=$should_deploy" >> $GITHUB_OUTPUT - name: Checkout Code uses: actions/checkout@v4 @@ -69,9 +82,9 @@ jobs: deploy: name: Deploy - if: ${{ github.ref == 'refs/heads/main' }} + if: ${{ needs.plan.outputs.should_deploy == 'true' }} needs: plan - environment: ${{ inputs.azure_environment == 'prod' && 'production' || 'staging' }} + environment: ${{ github.event_name != 'pull_request' && (inputs.azure_environment == 'prod' && 'production' || 'staging') || '' }} runs-on: ubuntu-24.04 steps: diff --git a/.github/workflows/cloud-infrastructure.yml b/.github/workflows/cloud-infrastructure.yml index ac71f83f53..81c4c25226 100644 --- a/.github/workflows/cloud-infrastructure.yml +++ b/.github/workflows/cloud-infrastructure.yml @@ -24,7 +24,7 @@ permissions: jobs: stage: name: Staging - if: ${{ github.ref == 'refs/heads/main' && vars.STAGING_CLUSTER_ENABLED == 'true' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Deploy to Staging')) }} + if: ${{ vars.STAGING_CLUSTER_ENABLED == 'true' }} uses: ./.github/workflows/_deploy-infrastructure.yml secrets: inherit with: