CI/CD Integration
Automate agent deployments with CI/CD pipelines
CI/CD Integration
Automate your SwiftClaw agent deployments with continuous integration and delivery.
GitHub Actions
Basic Workflow
name: Deploy Agent
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install SwiftClaw CLI
run: npm install -g @swiftclaw/cli
- name: Deploy Agent
env:
SWIFTCLAW_TOKEN: ${{ secrets.SWIFTCLAW_TOKEN }}
run: |
swiftclaw login --token $SWIFTCLAW_TOKEN
swiftclaw deploy my-agent --env productionAdvanced Workflow with Testing
name: Test and Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Tests
run: npm test
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy to Production
env:
SWIFTCLAW_TOKEN: ${{ secrets.SWIFTCLAW_TOKEN }}
run: |
swiftclaw login --token $SWIFTCLAW_TOKEN
swiftclaw deploy my-agent --env production --waitGitLab CI
# .gitlab-ci.yml
stages:
- test
- deploy
test:
stage: test
script:
- npm install
- npm test
deploy:
stage: deploy
only:
- main
script:
- npm install -g @swiftclaw/cli
- swiftclaw login --token $SWIFTCLAW_TOKEN
- swiftclaw deploy my-agent --env production
environment:
name: productionCircleCI
# .circleci/config.yml
version: 2.1
jobs:
test:
docker:
- image: cimg/node:18.0
steps:
- checkout
- run: npm install
- run: npm test
deploy:
docker:
- image: cimg/node:18.0
steps:
- checkout
- run: npm install -g @swiftclaw/cli
- run: |
swiftclaw login --token $SWIFTCLAW_TOKEN
swiftclaw deploy my-agent --env production
workflows:
test-and-deploy:
jobs:
- test
- deploy:
requires:
- test
filters:
branches:
only: mainEnvironment-Specific Deployments
Deploy to different environments based on branch:
name: Multi-Environment Deploy
on:
push:
branches: [main, staging, develop]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Determine Environment
id: env
run: |
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "environment=production" >> $GITHUB_OUTPUT
elif [ "${{ github.ref }}" == "refs/heads/staging" ]; then
echo "environment=staging" >> $GITHUB_OUTPUT
else
echo "environment=development" >> $GITHUB_OUTPUT
fi
- name: Deploy
env:
SWIFTCLAW_TOKEN: ${{ secrets.SWIFTCLAW_TOKEN }}
run: |
swiftclaw login --token $SWIFTCLAW_TOKEN
swiftclaw deploy my-agent --env ${{ steps.env.outputs.environment }}Deployment Strategies
Blue-Green Deployment
# Deploy new version (green)
swiftclaw deploy my-agent --env production --slot green
# Test green deployment
swiftclaw test my-agent --slot green
# Switch traffic to green
swiftclaw swap my-agent --from blue --to greenCanary Deployment
# Deploy canary with 10% traffic
swiftclaw deploy my-agent --env production --canary 10
# Monitor metrics
swiftclaw metrics my-agent --canary
# Promote canary to 100%
swiftclaw promote my-agent --canarySecrets Management
Never commit secrets: Use your CI/CD platform's secret management.
GitHub Secrets
- Go to repository Settings → Secrets
- Add
SWIFTCLAW_TOKEN - Reference in workflow:
${{ secrets.SWIFTCLAW_TOKEN }}
Environment Variables
env:
SWIFTCLAW_TOKEN: ${{ secrets.SWIFTCLAW_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}Deployment Notifications
Slack Notifications
- name: Notify Slack
if: always()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: 'Agent deployment ${{ job.status }}'
webhook_url: ${{ secrets.SLACK_WEBHOOK }}Discord Notifications
- name: Notify Discord
if: always()
run: |
curl -X POST ${{ secrets.DISCORD_WEBHOOK }} \
-H "Content-Type: application/json" \
-d '{"content": "Agent deployment ${{ job.status }}"}'Next Steps
How is this guide ?
Last updated on