diff --git a/Makefile b/Makefile index 4af2e6c9d390f7046010a0dbc58553156dfd7064..ac8327ac1742903f8011c7d1851e1b22233703ee 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,8 @@ backports: @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.state_name \]\]/$$TF_STATE_NAME/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.auto_apply \]\]/$$TF_AUTO_APPLY/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.auto_destroy \]\]/$$TF_AUTO_DESTROY/' + @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.create_destroy_job \]\]/$$TF_CREATE_DESTROY_JOB/' + @sed -i $(BACKPORTS_BASE_FILE) -e 's/$$\[\[ inputs.create_delete_state_job \]\]/$$TF_CREATE_DELETE_STATE_JOB/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/\.default/.opentofu:default/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/^fmt:$$/.opentofu:fmt:/' @sed -i $(BACKPORTS_BASE_FILE) -e 's/^validate:$$/.opentofu:validate:/' diff --git a/backports/OpenTofu/Base.gitlab-ci.yml b/backports/OpenTofu/Base.gitlab-ci.yml index beb26ab1ea3ee627fedd9aac238798ea7aef3df0..081da91b22891de49b0ffe325f8d8a22b0a033a3 100644 --- a/backports/OpenTofu/Base.gitlab-ci.yml +++ b/backports/OpenTofu/Base.gitlab-ci.yml @@ -109,6 +109,8 @@ variables: action: stop resource_group: $TF_STATE_NAME rules: + - if: '"$TF_CREATE_DESTROY_JOB" != "true"' + when: never - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && "$TF_AUTO_DESTROY" == "true"' - when: manual @@ -120,4 +122,9 @@ variables: - when: never script: - curl --request DELETE -u "gitlab-ci-token:$CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/terraform/state/$TF_STATE_NAME" + rules: + - if: '"$TF_CREATE_DELETE_STATE_JOB" != "true"' + when: never + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + - when: manual diff --git a/templates/full-pipeline.yml b/templates/full-pipeline.yml index cb5b83404318cbcd030b944f872de87df1ea3088..d243a261247c16ad1d90eb5a17f03ea371f6cf21 100644 --- a/templates/full-pipeline.yml +++ b/templates/full-pipeline.yml @@ -49,6 +49,12 @@ spec: auto_destroy: default: 'false' description: 'Whether the destroy job is manual or automatically run.' + create_destroy_job: + default: 'false' + description: 'Wheather the destroy job should be created or not.' + create_delete_state_job: + default: 'false' + description: 'Wheather the delete-state job should be created or not.' --- @@ -137,6 +143,8 @@ destroy: action: stop resource_group: $[[ inputs.state_name ]] rules: + - if: '"$[[ inputs.create_destroy_job ]]" != "true"' + when: never - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && "$[[ inputs.auto_destroy ]]" == "true"' - when: manual @@ -149,4 +157,9 @@ delete-state: - when: never script: - curl --request DELETE -u "gitlab-ci-token:$CI_JOB_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/terraform/state/$[[ inputs.state_name ]]" + rules: + - if: '"$[[ inputs.create_delete_state_job ]]" != "true"' + when: never + - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + - when: manual