diff --git a/.github/workflows/on_schedule_nightly.yml b/.github/workflows/on_schedule_nightly.yml index eab7727..2f9a7ed 100644 --- a/.github/workflows/on_schedule_nightly.yml +++ b/.github/workflows/on_schedule_nightly.yml @@ -3,7 +3,7 @@ name: nightly restage on: schedule: # 3am UTC - - cron: '0 3 * * *' + - cron: "0 3 * * *" jobs: restage: @@ -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 diff --git a/.github/workflows/reusable_deploy.yml b/.github/workflows/reusable_deploy.yml index 93cca17..be09f35 100644 --- a/.github/workflows/reusable_deploy.yml +++ b/.github/workflows/reusable_deploy.yml @@ -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 }} @@ -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 diff --git a/.github/workflows/wait-for-database.sh b/.github/workflows/wait-for-database.sh new file mode 100755 index 0000000..f25dc53 --- /dev/null +++ b/.github/workflows/wait-for-database.sh @@ -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