diff --git a/.github/workflows/clone-staging.yaml b/.github/workflows/clone-db.yaml similarity index 60% rename from .github/workflows/clone-staging.yaml rename to .github/workflows/clone-db.yaml index ef259c3b6..ee91cdca2 100644 --- a/.github/workflows/clone-staging.yaml +++ b/.github/workflows/clone-db.yaml @@ -1,4 +1,9 @@ -name: Clone Staging Database +# This workflow runs at the top of every hour and can be manually run as needed +# The workflow will copy the database from stable (production) to our staging sandbox. +# This workflow may fail if changes to the database schema make objects in stable +# incompatible with staging. This should resolve once both schemas match again. + +name: Clone Stable Database on: schedule: @@ -8,16 +13,19 @@ on: workflow_dispatch: env: - DESTINATION_ENVIRONMENT: ms - SOURCE_ENVIRONMENT: staging +# sandbox receiving the cloned db + DESTINATION_ENVIRONMENT: staging +# sandbox we are cloning + SOURCE_ENVIRONMENT: stable jobs: clone-database: runs-on: ubuntu-24.04 env: - CF_USERNAME: ${{ secrets.CF_MS_USERNAME }} - CF_PASSWORD: ${{ secrets.CF_MS_PASSWORD }} + # must be the github secrets for the receiving sandbox + CF_USERNAME: ${{ secrets.CF_STAGING_USERNAME }} + CF_PASSWORD: ${{ secrets.CF_STAGING_PASSWORD }} steps: - uses: GitHubSecurityLab/actions-permissions/monitor@v1 - name: Clone Database @@ -43,6 +51,16 @@ jobs: # clone from source to destination cf target -s $SOURCE_ENVIRONMENT cg-manage-rds clone getgov-$SOURCE_ENVIRONMENT-database getgov-$DESTINATION_ENVIRONMENT-database + + - name: Load Fixtures + uses: cloud-gov/cg-cli-tools@main + with: + cf_username: ${{ secrets.CF_STAGING_USERNAME }} + cf_password: ${{ secrets.CF_STAGING_PASSWORD }} + cf_org: cisa-dotgov + cf_space: ${{ env.DESTINATION_ENVIRONMENT }} + cf_command: "run-task getgov-staging --command 'python manage.py load' --name fixtures" + - name: Cleanup if: always() run: cf unshare-service getgov-$DESTINATION_ENVIRONMENT-database -s $SOURCE_ENVIRONMENT -f