Skip to content

Commit

Permalink
Merge pull request #2987 from cisagov/ms/2901-clone-staging-workflow
Browse files Browse the repository at this point in the history
Ms/2901 clone staging workflow
  • Loading branch information
Matt-Spence authored Oct 29, 2024
2 parents 7eee998 + 027870e commit 5e58f6d
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions .github/workflows/clone-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,41 @@ on:
env:
DESTINATION_ENVIRONMENT: ms
SOURCE_ENVIRONMENT: staging


jobs:
clone-database:
runs-on: ubuntu-latest
env:
CF_USERNAME: CF_${{ env.SOURCE_ENVIRONMENT }}_USERNAME
CF_PASSWORD: CF_${{ env.SOURCE_ENVIRONMENT }}_PASSWORD
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Cloud Foundry CLI
- name: Share DB Service
uses: cloud-gov/cg-cli-tools@main

- name: Clone
env:
CF_USERNAME: CF_${{ env.DESTINATION_ENVIRONMENT }}_USERNAME
CF_PASSWORD: CF_${{ env.DESTINATION_ENVIRONMENT }}_PASSWORD
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 }}
# install cg-manage-rds tool
pip install git+https://github.com/cloud-gov/cg-manage-rds.git
# share the sandbox db with the Staging space
cf share-service getgov-${{ env.DESTINATION_ENVIRONMENT }}-database -s ${{ env.SOURCE_ENVIRONMENT }}
# target the Staging space
cf target -s ${{ env.SOURCE_ENVIRONMENT }}
# clone from staging to the sandbox
cg-manage-rds clone getgov-${{ env.SOURCE_ENVIRONMENT }}-database getgov-${{ env.DESTINATION_ENVIRONMENT }}-database
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 }}
with:
cf_username: ${{ secrets[env.CF_USERNAME] }}
cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf_org: cisa-dotgov
cf_space: ${{ env.DESTINATION_ENVIRONMENT }}
cf_command: share-service getgov-${{ env.DESTINATION_ENVIRONMENT }}-database -s ${{ env.SOURCE_ENVIRONMENT }}

- name: Clone Database
uses: cloud-gov/cg-cli-tools@main
with:
cf_username: ${{ secrets.CF_MS_USERNAM }}
cf_password: ${{ secrets.CF_MS_PASSWORD }}
cf_org: cisa-dotgov
cf_space: ${{ env.SOURCE_ENVIRONMENT }}
command: cg-manage-rds clone getgov-${{ env.SOURCE_ENVIRONMENT }}-database getgov-${{ env.DESTINATION_ENVIRONMENT }}-database

- name: Unshare DB Service
uses: cloud-gov/cg-cli-tools@main
with:
cf_username: ${{ secrets.CF_MS_USERNAM }}
cf_password: ${{ secrets.CF_MS_PASSWORD }}
cf_org: cisa-dotgov
cf_space: ${{ env.SOURCE_ENVIRONMENT }}
cf_command: unshare-service getgov-${{ env.DESTINATION_ENVIRONMENT }}-database -s ${{ env.SOURCE_ENVIRONMENT }}

0 comments on commit 5e58f6d

Please sign in to comment.