Skip to content

Commit

Permalink
fix:correct branch selection
Browse files Browse the repository at this point in the history
  • Loading branch information
tunacinsoy committed Jul 26, 2024
1 parent 6dc02f7 commit c2880fa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/create-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ jobs:
id: get_tag
run: echo "::set-output name=tag::$(echo ${GITHUB_REF#refs/tags/})"

- name: Get Branch Name
id: get_branch
run: |
branch=$(git branch --contains $(git rev-parse ${GITHUB_SHA}) | sed -n -e 's/^\* \(.*\)/\1/p')
echo "::set-output name=branch::${branch}"
- name: Terraform Init
id: terraform-init
run: terraform init -backend-config="bucket=tf-state-${{ secrets.PROJECT_ID }}"
Expand All @@ -43,7 +49,7 @@ jobs:
if: contains(steps.get_tag.outputs.tag, 'destroy')
run: |
echo "Running destroy steps"
terraform destroy -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="branch=${GITHUB_REF##*/}"
terraform destroy -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="branch=${{ steps.get_branch.outputs.branch }}"
env:
GOOGLE_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}

Expand All @@ -52,6 +58,6 @@ jobs:
if: "!contains(steps.get_tag.outputs.tag, 'destroy')"
run: |
echo "Running apply steps"
terraform apply -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="branch=${GITHUB_REF##*/}"
terraform apply -auto-approve -var="project_id=${{ secrets.PROJECT_ID }}" -var="branch=${{ steps.get_branch.outputs.branch }}"
env:
GOOGLE_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}

0 comments on commit c2880fa

Please sign in to comment.