π GitHub Integration
ai+me integrates seamlessly with GitHub Actions to bring AI security testing into your CI/CD pipeline. This enables automated security validation of your AI applications on every pull request, ensuring that code changes don't introduce security vulnerabilities before they reach production.
π― What is GitHub Integration?
GitHub integration with ai+me allows you to automatically trigger experiments when code changes are made, providing:
- π Automated Security Testing: Run AI security tests on every PR
- π Early Vulnerability Detection: Catch security issues before deployment
- π Continuous Compliance: Maintain security standards across all changes
- π Seamless Workflow: Integrate security testing into existing CI/CD processes
π Setting Up GitHub Integration
Step 1: Prepare Your Experiment
Before setting up GitHub integration, you need a configured experiment in ai+me:
- Create an Experiment: Set up your AI security testing experiment
- Test Manually: Run the experiment manually to verify it works
- Note Integration Details: You'll need the experiment endpoint URL
Step 2: Access Integration Settings
- Navigate to Your Experiment: Go to your experiment in ai+me
- Open Settings: Click on the Settings tab
- Select Integration: Choose the Integration sub-tab
- View Integration Details: You'll see the endpoint URL and GitHub Action example
Step 3: Get Required Information
From the experiment integration page, you'll need:
Experiment Endpoint URL
- Location: Displayed prominently on the integration page
- Format:
https://api.aiandme.io/experiments/{experiment-id}
Project API Key
- Location: Link to project settings from the integration page
- Path:
/projects/{project-id}/settings/integration
Step 4: Create GitHub Actions Workflow
Create a .github/workflows/aiandme-security.yml
file in your repository:
name: AIandMe Security Testing
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [main, develop]
jobs:
security-test:
runs-on: ubuntu-latest
name: AI Security Testing
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run AI Security Experiment
env:
API_KEY: ${{ secrets.PROJECT_API_KEY }}
ENDPOINT_URL: ${{ secrets.EXPERIMENT_CLONE_ENDPOINT }}
PROVIDER_ID: ${{ secrets.PROVIDER_ID }}
run: |
echo "π Triggering AI security experiment..."
# Trigger the experiment
response=$(curl -s -w "%{http_code}" -X POST "$ENDPOINT_URL" \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider_id": "$PROVIDER_ID"
}')
# Extract status code and response body
http_code="${response: -3}"
response_body="${response%???}"
if [ "$http_code" -eq 200 ] || [ "$http_code" -eq 201 ]; then
echo "β
Experiment triggered successfully"
echo "π Check your AIandMe dashboard for results and insights"
else
echo "β Failed to trigger experiment (HTTP $http_code)"
echo "Response: $response_body"
exit 1
fi
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'π AI security testing has been triggered. Check your [AIandMe dashboard](https://app.aiandme.io) for results and insights.'
})