Sync Action
The Sync Action copies databases and files between Quant Cloud environments, perfect for refreshing staging with production data or setting up preview environments.
Repository: quantcdn/quant-cloud-environment-sync-action
What It Does
Section titled “What It Does”- Syncs databases between environments
- Syncs files/volumes between environments
- Waits for completion with configurable timeouts
- Ensures data consistency
Basic Usage
Section titled “Basic Usage”Sync database from production to staging:
- uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: my-org app_name: my-app environment_name: staging source: production type: databaseSync Database Only
Section titled “Sync Database Only”- uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: my-org app_name: my-app environment_name: staging source: production type: databaseSync Files Only
Section titled “Sync Files Only”- uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: my-org app_name: my-app environment_name: staging source: production type: filesystemWait for Completion
Section titled “Wait for Completion”Wait for the sync to complete before proceeding:
- uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: my-org app_name: my-app environment_name: staging source: production type: database wait: true wait_interval: 10 max_retries: 30Common Workflows
Section titled “Common Workflows”Nightly Staging Refresh
Section titled “Nightly Staging Refresh”Automatically refresh staging with production data:
name: Refresh Staging
on: schedule: - cron: '0 2 * * *' # 2 AM daily workflow_dispatch: # Allow manual trigger
jobs: sync: runs-on: ubuntu-latest steps: # Sync database - uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: ${{ secrets.QUANT_ORGANIZATION }} app_name: my-app environment_name: staging source: production type: database wait: true
# Sync filesystem - uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: ${{ secrets.QUANT_ORGANIZATION }} app_name: my-app environment_name: staging source: production type: filesystem wait: true
- name: Notify team run: echo "✅ Staging refreshed with production data"Manual Sync with Approval
Section titled “Manual Sync with Approval”Require manual approval before syncing:
name: Sync to Staging
on: workflow_dispatch: inputs: sync_type: description: 'Type of sync' type: choice options: - database - filesystem default: database
jobs: sync: runs-on: ubuntu-latest environment: sync-approval # Requires approval steps: - uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: ${{ secrets.QUANT_ORGANIZATION }} app_name: my-app environment_name: staging source: production type: ${{ inputs.sync_type }} wait: truePrepare PR Preview with Data
Section titled “Prepare PR Preview with Data”Create preview environment with production data:
on: pull_request: types: [opened]
jobs: preview: runs-on: ubuntu-latest steps: - uses: quantcdn/quant-cloud-init-action@v1 id: init
# Create PR preview environment - uses: quantcdn/quant-cloud-environment-action@v1 with: operation: create environment_name: pr-${{ github.event.number }}
# Sync production data to preview - uses: quantcdn/quant-cloud-environment-sync-action@v1 with: api_key: ${{ secrets.QUANT_API_KEY }} organization: ${{ secrets.QUANT_ORGANIZATION }} app_name: ${{ steps.init.outputs.quant_application }} environment_name: pr-${{ github.event.number }} source: production type: database wait: trueInputs
Section titled “Inputs”api_key: Quant API key (required)organization: Quant organisation ID (required)app_name: Name of your application (required)environment_name: Name for the target environment (required)source: Name of the source environment (required)type: Type of data to sync -databaseorfilesystem(optional, default:database)wait: Whether to wait for the sync to complete (optional, default:false)wait_interval: Interval in seconds between status checks (optional, default:10)max_retries: Maximum number of retries before timing out (optional, default:30)base_url: Quant Cloud API URL (optional, default:https://dashboard.quantcdn.io/api/v3)
Best Practices
Section titled “Best Practices”- Use scheduled workflows for regular refreshes
- Require approval for production syncs
- Test sync operations on non-production environments first
- Document sync schedule so team knows when data refreshes
- Consider file size - large file syncs can take time
- Use
wait: truewhen you need to ensure sync completes before proceeding - Adjust
max_retriesbased on expected sync duration (default timeout: 5 minutes)
Next Steps
Section titled “Next Steps”- Backup Action - Create backups before syncing
- Init Action - Environment detection