From de2848e30c911b4b1edcbe8fc9d7bceb234cc121 Mon Sep 17 00:00:00 2001 From: miampf Date: Mon, 4 Mar 2024 14:26:54 +0100 Subject: [PATCH] only upload directories if they exist only delete resources if resources are left over added missing semicolons asdf same directory checks for constellation-iam-terraform --- .../e2e_cleanup_timeframe/e2e-cleanup.sh | 20 +++++++++++-------- .github/workflows/e2e-test.yml | 15 +++++++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh b/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh index c5199ed3e..26aecbc8d 100755 --- a/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh +++ b/.github/actions/e2e_cleanup_timeframe/e2e-cleanup.sh @@ -13,18 +13,22 @@ function download_tfstate_artifact { # delete_resources runs terraform destroy on the constellation-terraform subfolder of a given folder. function delete_resources { - cd "$1/constellation-terraform" || exit 1 - terraform init > /dev/null || exit 1 # first, install plugins - terraform destroy -auto-approve || exit 1 - cd ../../ || exit 1 + if [ -d "$1/constellation-terraform" ]; then + cd "$1/constellation-terraform" || exit 1 + terraform init > /dev/null || exit 1 # first, install plugins + terraform destroy -auto-approve || exit 1 + cd ../../ || exit 1 + fi } # delete_iam_config runs terraform destroy on the constellation-iam-terraform subfolder of a given folder. function delete_iam_config { - cd "$1/constellation-iam-terraform" || exit 1 - terraform init > /dev/null || exit 1 # first, install plugins - terraform destroy -auto-approve || exit 1 - cd ../../ || exit 1 + if [ -d "$1/constellation-iam-terraform" ]; then + cd "$1/constellation-iam-terraform" || exit 1 + terraform init > /dev/null || exit 1 # first, install plugins + terraform destroy -auto-approve || exit 1 + cd ../../ || exit 1 + fi } # check if the password for artifact decryption was given diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index d28f6289b..7d89b6327 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -283,11 +283,16 @@ jobs: if: always() shell: bash run: | - rm -r to-zip/* - cp -r constellation-terraform to-zip - cp -r constellation-iam-terraform to-zip - rm to-zip/constellation-terraform/plan.zip - rm -rf to-zip/constellation-terraform/.terraform to-zip/constellation-iam-terraform/.terraform + rm -rf to-zip/* + if [ -d constellation-terraform ]; then + cp -r constellation-terraform to-zip + rm to-zip/constellation-terraform/plan.zip + rm -rf to-zip/constellation-terraform/.terraform + fi + if [ -d constellation-iam-terraform ]; then + cp -r constellation-iam-terraform to-zip + rm -rf to-zip/constellation-iam-terraform/.terraform + fi - name: Update tfstate if: always()