Merge pull request #3061 from cisagov/ms/2903-clone-stable-to-staging

#2903: Target Stable/Staging for Clone Workflow
This commit is contained in:
Matt-Spence 2024-11-14 17:08:11 -05:00 committed by GitHub
commit a872893d00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: on:
schedule: schedule:
@ -8,16 +13,19 @@ on:
workflow_dispatch: workflow_dispatch:
env: env:
DESTINATION_ENVIRONMENT: ms # sandbox receiving the cloned db
SOURCE_ENVIRONMENT: staging DESTINATION_ENVIRONMENT: staging
# sandbox we are cloning
SOURCE_ENVIRONMENT: stable
jobs: jobs:
clone-database: clone-database:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
env: env:
CF_USERNAME: ${{ secrets.CF_MS_USERNAME }} # must be the github secrets for the receiving sandbox
CF_PASSWORD: ${{ secrets.CF_MS_PASSWORD }} CF_USERNAME: ${{ secrets.CF_STAGING_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_STAGING_PASSWORD }}
steps: steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1 - uses: GitHubSecurityLab/actions-permissions/monitor@v1
- name: Clone Database - name: Clone Database
@ -43,6 +51,16 @@ jobs:
# clone from source to destination # clone from source to destination
cf target -s $SOURCE_ENVIRONMENT cf target -s $SOURCE_ENVIRONMENT
cg-manage-rds clone getgov-$SOURCE_ENVIRONMENT-database getgov-$DESTINATION_ENVIRONMENT-database 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 - name: Cleanup
if: always() if: always()
run: cf unshare-service getgov-$DESTINATION_ENVIRONMENT-database -s $SOURCE_ENVIRONMENT -f run: cf unshare-service getgov-$DESTINATION_ENVIRONMENT-database -s $SOURCE_ENVIRONMENT -f