CI/CD Integration Guide
CI/CD Integration Guide
This guide walks you through integrating Seedfast into your CI/CD pipelines. By the end, you'll have automated database seeding running in GitHub Actions, GitLab CI, CircleCI, or Jenkins.
Before you begin
Make sure you have:
• A Seedfast account
• A PostgreSQL, MySQL, or SQL Server database accessible from your CI/CD environment
• Access to configure secrets in your CI/CD platform
Create your API key
API keys authenticate the Seedfast CLI in non-interactive environments where browser-based login isn't possible.
To generate an API key:
1. Log in to the Seedfast Dashboard
2. Navigate to Settings → API Keys
3. Click Create New Key
4. Copy the key immediately — it won't be shown again
Your API key looks like this:
💡 Tip: Create separate keys for each environment (dev, staging, production). This allows independent rotation and revocation.
Configure CI/CD secrets
Store your API key and database credentials as encrypted secrets in your CI/CD platform.
GitHub Actions:
Go to your repository → Settings → Secrets and variables → Actions → New repository secret. Add:
GitLab CI:
Go to your project → Settings → CI/CD → Variables. Add the same variables and mark them as Masked and Protected.
CircleCI:
Go to Project Settings → Environment Variables and add both secrets.
Install Seedfast in your pipeline
The simplest way is using npx — no installation required:
Or download the binary directly:
Write your first seeding command
The basic command structure for CI/CD:
The --scope flag describes what data to seed in plain English:
When --scope is provided, Seedfast automatically approves the seeding plan without prompting. This enables fully automated pipelines.
The --output flag controls output format:
• json — Machine-readable for scripts
• plain — Timestamped logs for CI
• interactive — Colors and spinners (default)
GitHub Actions example
Here's a complete workflow that seeds a test database before running E2E tests:
GitLab CI example
Validate seeding results
Use JSON output to validate seeding in scripts:
Exit codes
Handle these exit codes in your pipeline:
• 0 — Success
• 1 — Generic error
• 2 — Authentication failed (check API key)
• 3 — Database connection failed (check DATABASE_URL)
• 4 — Quota exceeded
Troubleshooting
"Authentication failed" in CI but works locally:
• Verify the secret name matches exactly
• Check for leading/trailing whitespace in the secret
• Ensure the API key hasn't been revoked
"Connection refused" to database:
• Wait for database health check to pass
• Use correct hostname (localhost for GitHub Actions, postgres for GitLab CI)
• Check firewall rules allow CI runner IPs
Security best practices
• Store API keys in CI/CD secret management — never commit to repo
• Use separate keys per environment
• Rotate keys every 90 days
• Limit key scope to seeding step only:
Next steps
You're now ready to automate database seeding in your pipelines. Start with one test job, refine your scope based on actual needs, then expand to more test suites.