Skip to content

Commit

Permalink
Only call terminus -n build:env:delete:ci and terminus -n build:env:d…
Browse files Browse the repository at this point in the history
…elete:pr when the current build will make a new multidev (#43)

* working on cleanup logic

* deletion checker

* updating multidev deletion logic

* fixing indenting

* fixing error

* removing testing files

* Delete contains-check.sh
  • Loading branch information
stevector authored Jun 9, 2020
1 parent b518c7d commit 863ce8e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/@orb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,35 @@ jobs:
paths:
- $PANTHEON_REPO_DIR

# terminus build:env:delete can take around a minute.
# So only run it when the current build needs to
# make a new Multidev environment.
- run:
name: Delete old Multidevs to make space for a potential new one
command: terminus -n build:env:delete:ci "$TERMINUS_SITE" --keep=2 --yes
name: Delete old Multidevs if this build needs to create a new one
command: |
if [[ $TERMINUS_ENV = ci-* || $TERMINUS_ENV = pr-* ]]
then
echo "May need to delete old ci- or pr- environments to make room for this one"
echo "Getting list of all environments"
export ENV_LIST=$(terminus env:list $TERMINUS_SITE --field=id)
echo "Checking if current environment is in list of existing environments"
if [[ $(echo "${ENV_LIST}" | grep -x ${TERMINUS_ENV}) ]]
then
echo "${TERMINUS_ENV} found in the list of environments"
exit 0
else
echo "${TERMINUS_ENV} not found in the list of environments."
echo "Running clean-up script to delete old pr- environments"
terminus -n build:env:delete:pr "$TERMINUS_SITE" --yes
if [[ $TERMINUS_ENV = ci-* ]]
then
echo "Running clean-up script to delete old ci- environments"
terminus -n build:env:delete:ci "$TERMINUS_SITE" --keep=2 --yes
else
echo "Skipping deletion of ci- envs"
fi
fi
fi
- run:
name: Copy code to the local clone of the Pantheon repository
Expand Down Expand Up @@ -162,7 +188,6 @@ jobs:
# Delete old multidev environments associated with a PR that has been
# merged or closed.
terminus -n build:env:delete:pr "$TERMINUS_SITE" --yes
# @todo, Check back with CircleCI DevRel team. They mentioned possibly
# adding a CircleCI-maintained Orb step to do this concept.
- run:
Expand Down

0 comments on commit 863ce8e

Please sign in to comment.