Skip to content

Commit

Permalink
add a plan workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alismx committed Oct 16, 2024
1 parent 41f77a9 commit 75a55a1
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
name: Deploy
run-name: Deploy to ${{ inputs.workspace }} by @${{ github.actor }}
name: Terraform (Plan||Apply)
run-name: Terraform ${{ inputs.workspace }} by @${{ github.actor }}

on:
workflow_dispatch:
inputs:
workspace:
description: 'The workspace to deploy to'
description: 'The workspace to terraform against'
required: true
type: choice
options:
- ""
- prod
terraform_action:
description: 'The terraform action to perform'
required: true
type: choice
options:
- plan
- apply

concurrency:
group: ${{ github.event.inputs.workspace }}-deploy
group: ${{ github.event.inputs.workspace }}-terraform
cancel-in-progress: false

permissions:
Expand Down Expand Up @@ -55,11 +62,14 @@ jobs:
PROJECT: ${{ vars.PROJECT }}
shell: bash
run: |
echo "WORKSPACE=$WORKSPACE" >> .env
echo "BUCKET=$BUCKET" >> .env
echo "DYNAMODB_TABLE=$DYNAMODB_TABLE" >> .env
echo "REGION=$REGION" >> .env
echo "owner = \"$OWNER\"" >> $WORKSPACE.tfvars
echo "project = \"$PROJECT\"" >> $WORKSPACE.tfvars
echo "region = \"$REGION\"" >> $WORKSPACE.tfvars
./deploy.sh -e $WORKSPACE --ci
terraform init \
-var-file="$WORKSPACE.tfvars" \
-backend-config "bucket=$BUCKET" \
-backend-config "dynamodb_table=$DYNAMODB_TABLE" \
-backend-config "region=$REGION" \
|| (echo "terraform init failed, exiting..." && exit 1)
terraform workspace select "$WORKSPACE"
terraform ${{ env.terraform_action }} -var-file="$WORKSPACE.tfvars"

0 comments on commit 75a55a1

Please sign in to comment.