From eb9cfb03ed28f7bf55cab70bc3a06886c66f7808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Wed, 8 May 2024 08:28:56 +0200 Subject: [PATCH] Fix tfstate update logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- .github/actions/update_tfstate/action.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/actions/update_tfstate/action.yml b/.github/actions/update_tfstate/action.yml index d0176ba52..59aab2f04 100644 --- a/.github/actions/update_tfstate/action.yml +++ b/.github/actions/update_tfstate/action.yml @@ -1,5 +1,5 @@ name: Update TFState -description: "Update the terraform state artifact." +description: "Update the terraform state artifact. We use this to either delete an artifact if the e2e test was cleaned up successfully or to update the artifact with the latest terraform state." inputs: name: @@ -11,33 +11,29 @@ inputs: encryptionSecret: description: "The encryption secret for the artifacts." required: true - skipDeletion: - description: "Don't try to delete the artifact before updating. You should only use this if you know that no artifact exists." - default: "false" - required: false runs: using: "composite" steps: - - name: Check if tfstate should be deleted - if: always() && inputs.skipDeletion == 'false' + - name: Check if uploaded tfstate can be deleted + if: always() shell: bash run: | - if [[ -d constellation-terraform ]] || [[ -d constellation-iam-terraform ]]; then + if [[ ! -d constellation-terraform ]] && [[ ! -d constellation-iam-terraform ]]; then echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV" else echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV" fi - name: Delete tfstate artifact if necessary - if: always() && env.DELETE_TF_STATE == 'true' && inputs.skipDeletion == 'false' + if: always() && env.DELETE_TF_STATE == 'true' uses: ./.github/actions/artifact_delete with: name: ${{ inputs.name }} workflowID: ${{ inputs.runID }} - - name: Prepare terraform state folders - if: always() + - name: Prepare left over terraform state folders + if: always() && env.DELETE_TF_STATE == 'false' shell: bash run: | rm -rf to-zip/*