Skip to main content
This workflow validates that the main branch is in a ready state for merging pull requests. It checks the migration status and ensures no pending migrations are running that could affect the merge process.

Workflow configuration

Authentication and environment variables

The workflow requires several environment variables to be set:
  • XATA_API_KEY: Your Xata API key (set as a GitHub secret)
  • XATA_ORGANIZATION_ID: Your Xata organization ID
  • XATA_PROJECT_ID: Your Xata project ID
  • XATA_BRANCH_ID: The ID of the main branch
  • XATA_BRANCH_NAME: The name of the main branch
  • XATA_DATABASE_NAME: Your database name
If you have the Xata CLI configured with your project locally, you can obtain these values with the following commands:

Workflow steps

1. Install Xata CLI

This step installs the Xata CLI using the official installer script and adds it to the GitHub Actions PATH.

2. Check Xata status

This step performs three checks:
  • Verifies CLI and connection status
  • Checks for any pending migrations
  • Views the current branch status

Concurrency control

The workflow uses GitHub Actions concurrency to prevent multiple runs from interfering with each other:
This ensures that:
  • Only one workflow run per branch is active at a time
  • New runs cancel any in-progress runs
  • Prevents race conditions during status checks

Best practices

  1. Set appropriate timeout
    • The workflow has a 10-minute timeout
    • Adjust based on your maximum migration duration
  2. Use environment variables
    • Store sensitive information in GitHub secrets
    • Use environment variables for configuration
  3. Handle migration states
    • Check for in-progress migrations
    • Prevent merging during active migrations
    • Provide clear error messages