add possibility to run tf from branch (#1297)

Co-authored-by: Azat Safin <azsafin@provectus.com>
This commit is contained in:
azatsafin 2021-12-21 12:12:39 +03:00 committed by GitHub
parent 223bf85b6b
commit 317d956c3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,9 +3,13 @@ on:
workflow_dispatch:
inputs:
applyTerraform:
description: 'Do you want to apply the infra-repo terraform? Possible values [yes/no]. If no is chosen only plan will be executed. If yes is chosen, terraform will be automatically applied.'
description: 'Do you want to apply the infra-repo terraform? Possible values [plan/apply].'
required: true
default: 'no'
default: 'plan'
KafkaUIInfraBranch:
description: 'Branch name of Kafka-UI-Infra repo, tf will be executed from this branch'
required: true
default: 'master'
jobs:
terraform:
@ -15,7 +19,7 @@ jobs:
- name: Clone infra repo
run: |
echo "Cloning repo..."
git clone https://kafka-ui-infra:${{ secrets.KAFKA_UI_INFRA_TOKEN }}@gitlab.provectus.com/provectus-internals/kafka-ui-infra.git --branch master
git clone https://kafka-ui-infra:${{ secrets.KAFKA_UI_INFRA_TOKEN }}@gitlab.provectus.com/provectus-internals/kafka-ui-infra.git --branch ${{ github.event.inputs.KafkaUIInfraBranch }}
echo "Cd to deployment..."
cd kafka-ui-infra/aws-infrastructure4eks/deployment
echo "TF_DIR=$(pwd)" >> $GITHUB_ENV
@ -51,13 +55,9 @@ jobs:
export TF_VAR_repo_user_key=${{ secrets.KAFKA_UI_INFRA_TOKEN }}
terraform plan --var-file="../envs/pro/eks.tfvars"
- name: Terraform plan status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform apply
id: apply
if: ${{ github.event.inputs.applyTerraform == 'yes' }}
if: ${{ github.event.inputs.applyTerraform == 'apply' }}
run: |
cd $TF_DIR
export TF_VAR_github_connector_access_token=${{ secrets.SOURCE_CONNECTOR_GITHUB_TOKEN }}