Destroy Server #185
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Destroy Server | |
on: | |
schedule: | |
- cron: "0 16 * * *" # run once a day at 12 AM (philippine standard time) | |
workflow_dispatch: | |
defaults: | |
run: | |
working-directory: ./terraform | |
jobs: | |
terraform: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
- name: Terraform Init | |
run: terraform init | |
- name: Terraform Validate | |
run: terraform validate | |
- run: echo "DROPLET_SIZE=$(terraform output -json | jq -r '.droplet_size.value // empty')" >> $GITHUB_ENV | |
- name: Terraform Destroy | |
run: terraform destroy -auto-approve | |
env: | |
DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }} | |
TF_VAR_droplet_size: ${{ env.DROPLET_SIZE }} |