Skip to content

Commit

Permalink
refactor clone job
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Spence committed Oct 25, 2024
1 parent 7edd044 commit 027870e
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: Clone
- 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 027870e

Please sign in to comment.