Skip to content

Commit

Permalink
Merge pull request #2978 from cisagov/ms/2901-clone-staging-workflow
Browse files Browse the repository at this point in the history
allow manual triggering of clone workflow
  • Loading branch information
Matt-Spence authored Oct 24, 2024
2 parents c87dcb0 + 852b910 commit 5e57c1e
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/clone-staging.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Clone Sandbox Database
name: Clone Staging Database

on:
# these will be uncommented after testing
Expand All @@ -8,9 +8,6 @@ on:
# - cron: '0 * * * *'
# Allow manual triggering
workflow_dispatch:
# ----
# run on PR for testing before merge.
# pull_request:

env:
DESTINATION_ENVIRONMENT: ms
Expand All @@ -26,24 +23,20 @@ jobs:
- name: Install Cloud Foundry CLI
uses: cloud-gov/cg-cli-tools@main

- name: Login to Cloud Foundry
- name: Clone
env:
CF_USERNAME: CF_${{ env.DESTINATION_ENVIRONMENT }}_USERNAME
CF_PASSWORD: CF_${{ env.DESTINATION_ENVIRONMENT }}_PASSWORD
with:
cf_username: ${{ secrets[env.CF_USERNAME] }}
cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf_org: cisa-dotgov
cf_space: ${{ env.DESTINATION_ENVIRONMENT }}
run: |
# login to cf cli
cf login -a api.fr.cloud.gov -u $CF_USERNAME -p $CF_PASSWORD -o cisa-dotgov -s ${{ env.DESTINATION_ENVIRONMENT }}
- name: Install manage-rds tool
run: |
# install cg-manage-rds tool
pip install git+https://github.com/cloud-gov/cg-manage-rds.git
- name: Clone Database
run: |
# share the sandbox db with the Staging space
cf share-service getgov-${{ env.DESTINATION_ENVIRONMENT }}-database -s ${{ env.SOURCE_ENVIRONMENT }}
Expand All @@ -53,15 +46,10 @@ jobs:
# clone from staging to the sandbox
cg-manage-rds clone getgov-${{ env.SOURCE_ENVIRONMENT }}-database getgov-${{ env.DESTINATION_ENVIRONMENT }}-database
# delete the local copy of the backup that gets created
rm db_backup.sql
# switch to the target sandbox space
cf target -s ${{ env.DESTINATION_ENVIRONMENT }}
# un-share the sandbox from Staging
cf unshare-service getgov-${{ env.DESTINATION_ENVIRONMENT }}-database -s ${{ env.SOURCE_ENVIRONMENT }}
- name: Logout from Cloud Foundry
if: always()
run: cf logout

0 comments on commit 5e57c1e

Please sign in to comment.