Workflow Configuration
Authentication and Environment Variables
The workflow requires several environment variables to be set:XATA_API_REFRESH_TOKEN
: Your Xata API refresh token (set as a GitHub secret)XATA_ORGANIZATIONID
: Your Xata organization IDXATA_PROJECTID
: Your Xata project IDXATA_BRANCHID
: The ID of the main branchXATA_BRANCHNAME
: The name of the main branchXATA_DATABASENAME
: Your database name
Required Permissions
The workflow requires the following GitHub permissions:Workflow Steps
1. Find Previous Comment
2. Checkout Code
3. Install Dependencies
- pnpm package manager
- Xata CLI
4. Check Status and Migration State
5. Create or Update Comment
6. Branch Management
7. Migration Handling
8. Environment Setup
9. Final Comment Update
Concurrency Control
The workflow uses GitHub Actions concurrency to prevent multiple runs from interfering with each other:- Only one workflow run per PR is active at a time
- New runs cancel any in-progress runs
- Prevents race conditions during branch creation
When to Use
Use this workflow when you want to:- Create isolated database environments for PRs
- Test database changes in isolation
- Provide preview environments for PR reviewers
- Automate database branch management
Best Practices
-
Set Appropriate Timeout
- The workflow has a 10-minute timeout
- Adjust based on your typical migration duration
-
Use Environment Variables
- Store sensitive information in GitHub secrets
- Use environment variables for configuration
-
Handle Migration States
- Check for in-progress migrations
- Complete pending migrations
- Apply new migrations
-
PR Communication
- Keep PR comments updated
- Provide clear connection instructions
- Include relevant warnings
Related Workflows
- Check Workflow - For validating main branch status
- Clone Workflow - For cloning databases in CI/CD