Skip to content

Commit

Permalink
Update cleanup job in config.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
longbui98 committed Nov 7, 2023
1 parent d5775c1 commit adb6ca1
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit adb6ca1

Please sign in to comment.