From adb6ca1746e010be970fd1678f928d328c857f98 Mon Sep 17 00:00:00 2001 From: longbui98 Date: Tue, 7 Nov 2023 13:09:06 +0700 Subject: [PATCH] Update cleanup job in config.yml --- .circleci/config.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b8cf1c5..26bf41f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -240,6 +240,7 @@ jobs: apk update apk add tar gzip apk add npm nodejs + apk add --no-cache curl apk add --update ansible aws-cli - run: name: Get backend url @@ -276,6 +277,7 @@ jobs: apk update apk add tar gzip apk add npm nodejs + apk add --no-cache curl apk add --update ansible aws-cli - run: name: Deploy backend @@ -347,6 +349,7 @@ jobs: apk add npm nodejs node -v npm -v + apk add --no-cache curl apk add --update ansible aws-cli - run: name: Update cloudfront distribution @@ -372,21 +375,12 @@ jobs: --no-paginate --output text) echo OldWorkflowID: "${OldWorkflowID}" echo CIRCLE_WORKFLOW_ID "${CIRCLE_WORKFLOW_ID:0:7}" - - export STACKS=($(aws cloudformation list-stacks --query "StackSummaries[*].StackName" \ - --stack-status-filter CREATE_COMPLETE --no-paginate --output text)) - echo Stack names: "${STACKS[@]}" - run: name: Remove old stacks and files command: | - if [[ "${STACKS[@]}" =~ "${OldWorkflowID}" ]] - then - aws s3 rm "s3://udapeople-${OldWorkflowID}" --recursive - aws cloudformation delete-stack --stack-name "udapeople-backend-${OldWorkflowID}" - aws cloudformation delete-stack --stack-name "udapeople-frontend-${OldWorkflowID}" - else - echo "==========================Error while delete old stacks==========================" - fi + aws s3 rm "s3://udapeople-${OldWorkflowID}" --recursive + aws cloudformation delete-stack --stack-name "udapeople-backend-${OldWorkflowID}" + aws cloudformation delete-stack --stack-name "udapeople-frontend-${OldWorkflowID}" workflows: default: