GitHub CI/CD Pipeline Setup Guide with Abacus.AI
Introduction​
This guide provides step-by-step instructions for setting up a GitHub CI/CD pipeline to automatically deploy your Abacus.AI AI workflows whenever changes are pushed to the master or main branch. The pipeline uses GitHub Actions and securely manages API keys through GitHub Secrets.
Step 1: Prepare Your Repository Structure​
Organize your repository with the following structure (any structure can be used, but this is the simplest you can use to actually test integration):
your-repo/
├── .github/
│ └── workflows/
│ └── deploy-agent.yml
├── src/
│ └── update_agent.py
├── requirements.txt
└── README.md
Step 2: Create the Requirements File​
Create a requirements.txt file in your repository root with the following content:
abacusai
Step 3: Create Your Python Update Script​
Save your agent code as src/update_agent.py. Here's a template with environment variable support for the API key:
update_agent.py (example template, the easiest way is to use "open with Notebook" in the Agent, and copy the contents of all of the cells, inside your update_agent.py):
import os
from abacusai import ApiClient
# Your agent configuration code here
def create_agent_workflow():
# Define your workflow nodes, graph, etc.
# This is where your agent logic goes
pass
# Get API key from environment variable
api_key = os.environ.get('ABACUS_API_KEY')
if not api_key:
raise Exception('ABACUS_API_KEY environment variable is not set')
# Initialize client with API key
client = ApiClient(api_key=api_key)
# Update the agent
agent = client.update_model(
model_id='your_model_id_here',
# Add your agent parameters here
workflow_graph=workflow_graph,
agent_interface=agent_interface,
# ... other parameters
)
# Wait for deployment to complete
agent.wait_for_publish()
print(f"Agent updated successfully: {agent}")
Step 4: Create GitHub Actions Workflow​
Create .github/workflows/deploy-agent.yml with the following content:
deploy-agent.yml:
name: Deploy Abacus AI Agent
on:
push:
branches:
- master
- main
paths:
- 'src/update_agent.py'
- '.github/workflows/deploy-agent.yml'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Deploy Agent to Abacus AI
env:
ABACUS_API_KEY: ${{ secrets.ABACUS_API_KEY }}
run: |
python src/update_agent.py
- name: Notify on success
if: success()
run: echo "Agent deployed successfully!"
- name: Notify on failure
if: failure()
run: echo "Agent deployment failed!"
Step 5: Configure GitHub Secret​
Set up your API key from Abacus as a GitHub Secret:
- Navigate to your GitHub repository
- Go to Settings → Secrets and variables → Actions
- Click "New repository secret"
- Add the secret with:
- Name:
ABACUS_API_KEY - Value: Your actual Abacus.AI API key
- Name:
To obtain your Abacus.AI API key:
- Log into your Abacus.AI account (abacus.ai/app)
- Navigate to your profile on the top right
- Click on "API Keys"
Step 6: Testing Your Pipeline​
To test your newly configured pipeline:
- Make a small change to your
src/update_agent.pyfile (e.g., add a comment) - Commit and push to master:
git add .
git commit -m "Test CI/CD pipeline"
git push origin master
- Check the GitHub Actions tab in your repository to monitor the workflow
- Verify the agent was updated in your Abacus.AI dashboard
Troubleshooting Common Issues​
- API Key Issues: Ensure the secret name matches exactly (
ABACUS_API_KEY) - Python Version: Verify the Python version in the workflow matches your local development
- Dependencies: Keep
requirements.txtupdated with all necessary packages from the AI Agent - Branch Names: Check your default branch name (master vs main)
- Path Triggers: Ensure file paths in the workflow match your repository structure
Optional Enhancements​
Consider these additional features for your pipeline:
- Environment-specific deployments (staging/production)
- Slack or email notifications for deployment status
- Automated testing before deployment
- Deployment approval workflows for production