mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-10 22:36:52 +00:00
fix(ci): robust terraform destroy with lock cleanup and re-init
Terraform destroy now handles cancelled runs gracefully: - Re-runs terraform init (in case it didn't complete) - Force-unlocks stale state locks from killed apply steps - Cleans up state files so next run starts fresh Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -221,4 +221,13 @@ jobs:
|
||||
TF_VAR_target_node: ${{ secrets.PVE_TARGET_NODE }}
|
||||
TF_VAR_iso_local_path: /tmp/${{ steps.iso.outputs.filename }}
|
||||
TF_VAR_test_vm_password: ${{ env.PVE_PASSWORD }}
|
||||
run: terraform destroy -auto-approve -input=false
|
||||
run: |
|
||||
terraform init -input=false
|
||||
# Clear stale lock from cancelled runs
|
||||
if [ -f .terraform.tfstate.lock.info ]; then
|
||||
LOCK_ID=$(python3 -c "import json; print(json.load(open('.terraform.tfstate.lock.info'))['ID'])")
|
||||
terraform force-unlock -force "$LOCK_ID" || true
|
||||
fi
|
||||
terraform destroy -auto-approve -input=false || true
|
||||
# Clean up state so next run starts fresh
|
||||
rm -f terraform.tfstate terraform.tfstate.backup .terraform.tfstate.lock.info
|
||||
|
||||
Reference in New Issue
Block a user