diff --git a/.github/workflows/deploy_terraform.yml b/.github/workflows/deploy_terraform.yml index b57fb9c2..b06a2468 100644 --- a/.github/workflows/deploy_terraform.yml +++ b/.github/workflows/deploy_terraform.yml @@ -3,7 +3,6 @@ name: CI/CD Pipeline on: push: branches: - - main - dev - prod @@ -49,12 +48,15 @@ jobs: run: cd infrastructure/terraform && terraform init - name: Terraform Plan - run: cd infrastructure/terraform && terraform plan -var-file=${{ github.event.pull_request.base.ref }}.tfvars + run: | + BRANCH_NAME=$(echo "${{ github.ref }}" | sed -e "s/^refs\/heads\///") + cd infrastructure/terraform && terraform plan -var-file=${BRANCH_NAME}.tfvars - name: Terraform Workspace run: | + BRANCH_NAME=$(echo "${{ github.ref }}" | sed -e "s/^refs\/heads\///") cd infrastructure/terraform - terraform workspace select ${{ github.event.pull_request.base.ref }} || terraform workspace new ${{ github.event.pull_request.base.ref }} + terraform workspace select ${BRANCH_NAME} || terraform workspace new ${BRANCH_NAME} - name: Deploy to Dev if: github.ref == 'refs/heads/dev'