Merge pull request #11 from Hestia-Homes/main

Pull out branch name from the environment github ref
This commit is contained in:
KhalimCK 2023-07-05 19:46:46 +01:00 committed by GitHub
commit 4eab76fed3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,7 +3,6 @@ name: CI/CD Pipeline
on: on:
push: push:
branches: branches:
- main
- dev - dev
- prod - prod
@ -49,12 +48,15 @@ jobs:
run: cd infrastructure/terraform && terraform init run: cd infrastructure/terraform && terraform init
- name: Terraform Plan - 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 - name: Terraform Workspace
run: | run: |
BRANCH_NAME=$(echo "${{ github.ref }}" | sed -e "s/^refs\/heads\///")
cd infrastructure/terraform 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 - name: Deploy to Dev
if: github.ref == 'refs/heads/dev' if: github.ref == 'refs/heads/dev'