Skip to content

Commit

Permalink
Fix getting environment value from branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
danifr committed Jan 14, 2025
1 parent 5b5dcf6 commit 262af78
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/terraform_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ENVIRONMENT: ${{ github.head_ref || github.ref_name }} # use branch name as deployment environment

runs-on: ubuntu-latest
name: Run terraform
Expand All @@ -19,12 +18,12 @@ jobs:
uses: hashicorp/setup-terraform@v3

- name: Initialize Terraform
run: terraform init -backend-config="./$ENVIRONMENT.config"
run: terraform init -backend-config="./${GITHUB_REF##*/}.config" # use branch name as deployment environment

- name: Run Terraform Plan
run: |
terraform plan -var="environment=$ENVIRONMENT"
terraform plan -var="environment=${GITHUB_REF##*/}"
#- name: Run Terraform Apply
# run: |
# terraform apply -auto-approve -var="environment=$ENVIRONMENT
# terraform apply -auto-approve -var="environment=${GITHUB_REF##*/}

0 comments on commit 262af78

Please sign in to comment.