Skip to content

Commit

Permalink
Merge pull request #3 from edgefarm/fix-delete
Browse files Browse the repository at this point in the history
Fix delete
  • Loading branch information
batthebee authored Apr 13, 2022
2 parents eb1fcca + 9ccd1dc commit 45c0076
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "terraform apply on hcloud"
name: "management cluster terraform apply on hcloud"

on:
workflow_call:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ on:
secrets:
tf_api_token:
required: true
hcloud_secret:
required: true
hcloud_ssh_key_private:
required: true
hcloud_ssh_key_public:
required: true

jobs:
terraform:
Expand All @@ -39,17 +45,27 @@ jobs:
with:
cli_config_credentials_token: ${{ secrets.tf_api_token }}

# Selecting correct workspace
- name: Terraform Workspace Select
run: terraform workspace select ${{ inputs.workspace }}

# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init
run: TF_WORKSPACE=fallback terraform init -input=false

# Destroy
# Selecting correct workspace (and create if not exist)
- name: Terraform Workspace Select
run: terraform workspace select ${{ inputs.workspace }} || terraform workspace new ${{ inputs.workspace }}

# Destroy ressources
- name: Terraform Destroy
run: terraform destroy -auto-approve
run: |
terraform destroy -auto-approve -var-file=${{ inputs.var_file }} \
-var prefix="${{ inputs.prefix }}" \
-var hcloud_secret="${{ secrets.hcloud_secret }}" \
-var hcloud_ssh_key_private="${{ secrets.hcloud_ssh_key_private }}" \
-var hcloud_ssh_key_public="${{ secrets.hcloud_ssh_key_public }}"
# Selecting fallback workspace
- name: Terraform Workspace Select
run: terraform workspace select fallback

# Delete workspace
- name: Terraform Workspace delete
run: terraform workspace delete -force ${{ inputs.workspace }}

0 comments on commit 45c0076

Please sign in to comment.