diff --git a/.github/workflows/clone-staging.yaml b/.github/workflows/clone-staging.yaml index 4fbb2ccb7..c82d1fa70 100644 --- a/.github/workflows/clone-staging.yaml +++ b/.github/workflows/clone-staging.yaml @@ -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 }} \ No newline at end of file