Skip to content

Commit

Permalink
Merge pull request #517 from 18F/resource-cleanup
Browse files Browse the repository at this point in the history
Remove the dev database along with the nightly shutdown
  • Loading branch information
mgwalker authored Nov 30, 2023
2 parents 8efdd11 + 65d2e71 commit 23b1b6f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/on_schedule_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: nightly restage
on:
schedule:
# 3am UTC
- cron: '0 3 * * *'
- cron: "0 3 * * *"

jobs:
restage:
Expand All @@ -27,3 +27,4 @@ jobs:
cf restage $CF_APP
cf target -s $CF_SPACE_DEV
cf stop $CF_APP
cf delete-service charlie-brain -f
5 changes: 5 additions & 0 deletions .github/workflows/reusable_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
with:
path: ./npm-cache
key: 18f-bot-${{ runner.os }}-npmcache-${{ hashFiles('package.json') }}-v1
- name: add extra deployment steps for dev
id: devSteps
if: ${{ inputs.environment == 'dev' }}
run: echo 'command="cf create-service aws-rds micro-psql charlie-brain; bash .github/workflows/wait-for-database.sh"' >> "$GITHUB_OUTPUT"
- name: push to cloud.gov
env:
CF_API: ${{ secrets.CF_API }}
Expand All @@ -35,4 +39,5 @@ jobs:
CF_USERNAME: ${{ secrets.CF_USERNAME }}
run: |
cf login -a $CF_API -u $CF_USERNAME -p $CF_PASSWORD -o $CF_ORG -s $CF_SPACE
${{ steps.devSteps.outputs.command }}
cf push -f manifest.yml --vars-file ./${{ inputs.environment }}.yml
9 changes: 9 additions & 0 deletions .github/workflows/wait-for-database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

STATUS="$(cf service charlie-brain | grep " status:" | awk -F ":" '{print $2}' | xargs)"
while [ "$STATUS" != "create succeeded" ]
do
echo "Waiting for database service to be ready..."
sleep 10
$STATUS=$(cf service charlie-brain | grep " status:" | awk -F ":" '{print $2}' | xargs)
done

0 comments on commit 23b1b6f

Please sign in to comment.