Skip to content

Commit

Permalink
set environment name properly
Browse files Browse the repository at this point in the history
  • Loading branch information
BobanL committed Dec 4, 2023
1 parent d016db1 commit 4902f95
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,25 @@ permissions:
contents: read
packages: write
jobs:
setEnv:
name: Set environment variable
runs-on: ubuntu-latest
steps:
- name: Set env
run: |-
echo "ENVIRONMENT=$(
if ${{ github.event.inputs.environment }}; then
echo ${{ github.event.inputs.environment }}
elif [ ${{ github.ref_name }} == main]; then
echo prod
else
echo dev2
fi
)" >> $GITHUB_ENV
terraform:
name: Run Terraform (${{github.event.inputs.environment}})
runs-on: ubuntu-latest
needs: [setEnv]
environment: main
defaults:
run:
Expand Down Expand Up @@ -82,11 +98,7 @@ jobs:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
run: |-
echo "tf_env=$(
if [[ "${{ github.event.inputs.environment }}" != "" ]]; then
echo ${{ github.event.inputs.environment }}
else
echo dev
fi
echo ${{ env.ENVIRONMENT }}
)" >> $GITHUB_OUTPUT
echo "short_cid=${CLIENT_ID:0:8}" >> $GITHUB_OUTPUT
Expand All @@ -97,6 +109,7 @@ jobs:
ARM_SUBSCRIPTION_ID: ${{ secrets.SUBSCRIPTION_ID }}
TF_ENV: ${{ steps.set-environment.outputs.tf_env }}
run: |
asdf
terraform init -backend-config=backend.tfvars
terraform workspace select -or-create $TF_ENV
terraform apply -auto-approve -lock-timeout=30m
Expand Down

0 comments on commit 4902f95

Please sign in to comment.