From 81755af369b440cd096b5e7bd8e09e61c16bca26 Mon Sep 17 00:00:00 2001 From: matthewswspence Date: Thu, 24 Oct 2024 14:56:53 -0500 Subject: [PATCH 1/2] allow manual triggering --- .github/workflows/clone-staging.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/clone-staging.yaml b/.github/workflows/clone-staging.yaml index 70830e831..df680baa5 100644 --- a/.github/workflows/clone-staging.yaml +++ b/.github/workflows/clone-staging.yaml @@ -1,4 +1,4 @@ -name: Clone Sandbox Database +name: Clone Staging Database on: # these will be uncommented after testing @@ -7,10 +7,7 @@ on: # # Run daily at 2:00 PM EST # - cron: '0 * * * *' # Allow manual triggering - # workflow_dispatch: - # ---- - # run on PR for testing before merge. - # pull_request: + workflow_dispatch: env: DESTINATION_ENVIRONMENT: ms From d8f2ec83b3b3bf04fd9da6ce76b66494f6cfe8fd Mon Sep 17 00:00:00 2001 From: matthewswspence Date: Thu, 24 Oct 2024 15:16:29 -0500 Subject: [PATCH 2/2] minor refactor --- .github/workflows/clone-staging.yaml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/clone-staging.yaml b/.github/workflows/clone-staging.yaml index df680baa5..4574987cd 100644 --- a/.github/workflows/clone-staging.yaml +++ b/.github/workflows/clone-staging.yaml @@ -23,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 }} @@ -50,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 \ No newline at end of file + cf unshare-service getgov-${{ env.DESTINATION_ENVIRONMENT }}-database -s ${{ env.SOURCE_ENVIRONMENT }} \ No newline at end of file