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
This commit is contained in:
miampf 2024-03-04 14:26:54 +01:00
parent f661e416ad
commit de2848e30c
No known key found for this signature in database
GPG Key ID: EF039364B5B6886C
2 changed files with 22 additions and 13 deletions

View File

@ -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

View File

@ -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()