Comprehensive CI workflows for testing, security scanning, and quality validation on every push.
CI/CD workflows execute automatically:
Continuous Integration and Continuous Deployment (CI/CD) provides the final layer of defense in your development workflow:
File: .github/workflows/security-ci.yml
Triggers: Push, Pull Request, Manual, Schedule (daily at 2 AM)
If security scans find issues:
File: .github/workflows/ci.yml
Triggers: Push, Pull Request
What it does: Scans the entire git history (not just current files) for secrets.
Example Detection:
Gitleaks found the following secrets:
Commit: abc123def456
File: config/settings.py
Secret: AWS Access Key
Line: aws_key = "AKIAIOSFODNN7EXAMPLE"
Action Required:
1. Remove secret from git history (git filter-branch or BFG)
2. Rotate the compromised credential
3. Use environment variables instead
Finds high-entropy strings that are likely to be passwords, API keys, or tokens.
Analyzes Python code for common security issues:
Static analysis for multiple languages with custom rules:
CI runs your test suite on every change:
# Example pytest run in CI
name: Run Tests
run: |
pytest tests/ \
--cov=src \
--cov-report=term \
--cov-report=html \
--verbose
# CI fails if:
# - Any test fails
# - Coverage drops below threshold (e.g., 80%)
# Clone Guardrails-AI repository
git clone https://github.com/christopherpaquin/Guardrails-AI .ai-guardrails
# Copy CI workflows
mkdir -p .github/workflows
cp .ai-guardrails/template/.github/workflows/* .github/workflows/
# Commit and push
git add .github/
git commit -m "Add CI/CD workflows"
git push origin main
# GitHub Actions automatically activates!
Use the management script to control which CI jobs run:
# List all workflows and jobs
./scripts/manage-ci-jobs.sh list
# Disable a specific job (if tests not ready yet)
./scripts/manage-ci-jobs.sh disable ci.yml tests
# Re-enable when ready
./scripts/manage-ci-jobs.sh enable ci.yml tests
# Show job configuration
./scripts/manage-ci-jobs.sh show security-ci.yml gitleaks
Edit workflow files to customize scanning:
# In .github/workflows/security-ci.yml
# Gitleaks - Add exclusions
with:
args: "--exclude-paths gitleaks.toml"
# Bandit - Change severity level
run: bandit -r src/ -ll # Only high/medium severity
# Semgrep - Custom rules
run: semgrep --config=p/security-audit src/
Enforce CI checks before merging:
main branchIf your CI needs credentials (e.g., for deployments):
# Add secrets to GitHub
# Settings → Secrets → Actions → New repository secret
# Use in workflow:
env:
API_KEY: ${{ secrets.API_KEY }}
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
Run security scans on a schedule (even without code changes):
on:
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
push:
pull_request:
Add comprehensive security scanning and testing to your repository.
View Workflow Templates