---
steps:
    - id: 'branch name'
      name: 'alpine'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            echo "***********************"
            echo "Branch: $BRANCH_NAME"
            echo "***********************"
    - id: 'tf init'
      name: 'hashicorp/terraform:0.12.20'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            cd $_TERRAFORM_ENVIRONMENT_PATH || exit 1
            terraform init || exit 1
            cd ../../
    - id: 'tf plan'
      name: 'hashicorp/terraform:0.12.20'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            cd $_TERRAFORM_ENVIRONMENT_PATH || exit 1
            terraform plan || exit 1
            cd ../../
    - id: 'tf apply'
      name: 'hashicorp/terraform:0.12.20'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            if [ "${BRANCH_NAME}" = "master" ]; then
                cd $_TERRAFORM_ENVIRONMENT_PATH || exit 1
                echo $BRANCH_NAME
                terraform apply -auto-approve || exit 1
            else
                echo "Not applying any Terraform change. Not on master branch."
                echo "Current branch: $BRANCH_NAME"
            fi
substitutions:
    _TERRAFORM_ENVIRONMENT_PATH: 'provisioning/terraform/environments/prod'

---
env:
    TF_INPUT=false
steps:
    - id: 'branch name'
      name: 'alpine'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            echo "***********************"
            echo "Branch: $BRANCH_NAME"
            echo "***********************"
    - id: 'tf init'
      name: 'hashicorp/terraform:0.12.20'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            cd $_TERRAFORM_ENVIRONMENT_PATH || exit 1
            terraform init || exit 1
            cd ../../
    - id: 'tf plan'
      name: 'hashicorp/terraform:0.12.20'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            cd $_TERRAFORM_ENVIRONMENT_PATH || exit 1
            terraform plan || exit 1
            cd ../../
    - id: 'tf apply'
      name: 'hashicorp/terraform:0.12.20'
      entrypoint: 'sh'
      args:
          - '-c'
          - |
            if [ "${BRANCH_NAME}" = "master" ]; then
                cd $_TERRAFORM_ENVIRONMENT_PATH || exit 1
                echo $BRANCH_NAME
                terraform apply -auto-approve || exit 1
            else
                echo "Not applying any Terraform change. Not on master branch."
                echo "Current branch: $BRANCH_NAME"
            fi
substitutions:
    _TERRAFORM_ENVIRONMENT_PATH: 'provisioning/terraform/environments/prod'

Disable terraform input in CI builds
Disable terraform input in CI builds
