Skip to content

Commit

Permalink
Added tf destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Abby Artagame committed Nov 11, 2024
1 parent 5c0fd08 commit 1124438
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/tf-plan-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,44 @@ jobs:
- name: Terraform Apply
run: |
terraform apply -auto-approve terraform.tfplan
terraform-destroy:
name: 'Terraform Destroy'
if: github.ref == 'refs/heads/main' && needs.terraform-plan.outputs.tfplanExitCode == 2
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./tf
environment: DEV
needs: [terraform-plan]

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v4

# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

# 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

# Download saved plan from artifacts
- name: Download Terraform Plan
uses: actions/download-artifact@v4
with:
path: tf
name: tfplan

# Terraform Plan Destroy - Check what to destroy
- name: Terraform Plan Destroy
run: |
terraform plan -destroy -auto-approve terraform.tfplan
# # Terraform Destroy
# - name: Terraform Destroy
# run: |
# terraform apply -auto-approve terraform.tfplan

0 comments on commit 1124438

Please sign in to comment.