CI/CD
Automate Strata deployments with continuous integration and delivery.
Learning Objectives
After completing this guide, you will be able to:
- Set up automated deployments
- Configure CI/CD pipelines
- Use deployment flags for automation
- Handle secrets securely
Overview
CI/CD automates the deployment of your semantic models, ensuring:
- Consistency - Same process every time
- Reliability - Automated validation and testing
- Speed - Deploy without manual steps
- Safety - Run audits and tests automatically
Basic CI/CD Setup
GitHub Actions Example
name: Deploy Strata Model
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.4'
- name: Install Strata CLI
run: gem install strata-cli
- name: Configure API Key
run: |
mkdir -p .strata
echo "api_key: ${{ secrets.STRATA_API_KEY }}" > .strata
- name: Deploy
run: strata deploy --yes
GitLab CI Example
deploy:
image: ruby:3.4.4
before_script:
- gem install strata-cli
- |
cat > .strata << EOF
api_key: ${STRATA_API_KEY}
EOF
script:
- strata deploy --yes
only:
- main
Deployment Flags for CI/CD
--yes (Skip Confirmation)
Required for non-interactive deployments:
strata deploy --yes
--skip-audit (Optional)
Skip pre-deployment audits (not recommended):
strata deploy --yes --skip-audit
--force (Force Deployment)
Deploy even if no files changed:
strata deploy --yes --force
--environment (Environment Selection)
Deploy to specific environment:
strata deploy --yes --environment production
Secure Secret Management
GitHub Secrets
- Go to repository Settings → Secrets and variables → Actions
- Add secret:
STRATA_API_KEY - Reference in workflow:
- name: Configure API Key
run: |
mkdir -p .strata
echo "api_key: ${{ secrets.STRATA_API_KEY }}" > .strata
GitLab CI Variables
- Go to Settings → CI/CD → Variables
- Add variable:
STRATA_API_KEY(masked) - Reference in
.gitlab-ci.yml:
script:
- |
cat > .strata << EOF
api_key: ${STRATA_API_KEY}
EOF
Environment-Specific Secrets
For multiple environments:
- name: Configure API Keys
run: |
mkdir -p .strata
cat > .strata << EOF
api_key: ${{ secrets.STRATA_API_KEY }}
environments:
production:
api_key: ${{ secrets.STRATA_PROD_API_KEY }}
staging:
api_key: ${{ secrets.STRATA_STAGING_API_KEY }}
EOF
Complete CI/CD Pipeline
With Testing
name: Deploy Strata Model
on:
push:
branches:
- main
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.4'
- run: gem install strata-cli
- run: strata audit
deploy:
needs: audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.4'
- run: gem install strata-cli
- name: Configure API Key
run: |
mkdir -p .strata
echo "api_key: ${{ secrets.STRATA_API_KEY }}" > .strata
- name: Deploy
run: strata deploy --yes
Multi-Environment
name: Deploy Strata Model
on:
push:
branches:
- main
- staging
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4.4'
- run: gem install strata-cli
- name: Configure API Key
run: |
mkdir -p .strata
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
ENV="production"
else
ENV="staging"
fi
echo "api_key: ${{ secrets.STRATA_API_KEY }}" > .strata
- name: Deploy
run: strata deploy --yes --environment $ENV
Best Practices
- Run audits first - Catch issues before deployment
- Use secrets - Never commit API keys
- Test in staging - Deploy to staging before production
- Monitor deployments - Check deployment status
- Use --yes flag - Required for automation
- Version control - Keep all model files in Git
Deployment Workflow
Recommended Flow
- Development - Make changes locally
- Commit - Commit to feature branch
- Pull Request - Open PR (optional: run audits in CI)
- Merge - Merge to main/staging
- Auto-Deploy - CI/CD deploys automatically
- Monitor - Check deployment status
Branch Strategy
- main → Production environment
- staging → Staging environment
- feature branches → Development (manual deploy)
Troubleshooting
CI/CD Deployment Fails
Check:
- API key is set correctly
- Server URL is configured
- Git repository is initialized
- Model files are valid
Solution:
- Verify secrets are set
- Run
strata auditlocally - Check CI/CD logs
Authentication Errors
Check:
- API key format is correct
.stratafile permissions (should be 0600)- API key has correct permissions
Solution:
- Verify secret value
- Check API key in Strata server
- Regenerate API key if needed
Advanced Patterns
Conditional Deployment
Deploy only on specific conditions:
- name: Deploy
if: github.ref == 'refs/heads/main'
run: strata deploy --yes --environment production
Deployment Notifications
Notify on deployment completion:
- name: Notify
if: always()
run: |
if [ $? -eq 0 ]; then
echo "Deployment succeeded"
else
echo "Deployment failed"
fi
Rollback Strategy
Keep previous deployments for rollback:
- name: Tag Deployment
if: success()
run: |
git tag "deploy-$(date +%Y%m%d-%H%M%S)"
git push --tags
Next Steps
- Learn about deployment details
- Read about testing in CI/CD
- Explore audit commands