From 7edd0448282dde5e08bc331814216e44a5b10768 Mon Sep 17 00:00:00 2001 From: matthewswspence Date: Fri, 25 Oct 2024 11:01:37 -0500 Subject: [PATCH 1/2] revert --- .github/workflows/clone-staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clone-staging.yaml b/.github/workflows/clone-staging.yaml index ebb0a1a82..4fbb2ccb7 100644 --- a/.github/workflows/clone-staging.yaml +++ b/.github/workflows/clone-staging.yaml @@ -20,7 +20,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Install Cloud Foundry CLI + - name: Clone uses: cloud-gov/cg-cli-tools@main - name: Clone From 027870e60a0110c9dcbcace07e207c9dce196605 Mon Sep 17 00:00:00 2001 From: matthewswspence Date: Fri, 25 Oct 2024 15:16:17 -0500 Subject: [PATCH 2/2] refactor clone job --- .github/workflows/clone-staging.yaml | 58 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) 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