diff --git a/templates/destroy.yml b/templates/destroy.yml index 267a0d801f36c6395cfbd25b8f5c847619679d03..2cb2b739917e45b55b8dadfc965334769e8bd7b2 100644 --- a/templates/destroy.yml +++ b/templates/destroy.yml @@ -45,6 +45,9 @@ spec: auto_destroy: default: 'false' description: 'Whether the destroy job is manual or automatically run.' + plan: + default: '' + description: 'Path to a previously generated destroy plan.' --- @@ -67,4 +70,11 @@ spec: image: name: '$[[ inputs.image_registry_base ]]/gitlab-opentofu:$[[ inputs.version ]]-opentofu$[[ inputs.opentofu_version ]]' script: - - gitlab-tofu destroy + - | + if [ -z '$[[ inputs.plan ]]' ]; then + echo 'gitlab-tofu destroy' + gitlab-tofu destroy + else + echo 'gitlab-tofu destroy "$[[ inputs.plan ]]"' + gitlab-tofu destroy "$[[ inputs.plan ]]" + fi