Antbase/Documentation

GitHub Actions Integration

Add AI-powered automation to your CI/CD pipeline with Antbase. Generate PR summaries, review code, create changelogs, and more -- all inside GitHub Actions workflows.

What this enables

  • AI-generated PR descriptions and code reviews
  • Automated changelog generation from commit history
  • Code quality checks using AI analysis
  • Translation and documentation generation in CI

Quick Start

1. Add your API key as a secret

Go to Settings > Secrets and variables > Actions in your GitHub repo and add ANTBASE_API_KEY as a repository secret.

2. Create a workflow

# .github/workflows/ai-pr-summary.yml
name: AI PR Summary
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  summarize:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get diff
        id: diff
        run: |
          DIFF=$(git diff origin/main...HEAD -- . ':!package-lock.json' ':!*.lock' | head -c 10000)
          echo "diff<<EOF" >> $GITHUB_OUTPUT
          echo "$DIFF" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Generate summary
        id: summary
        run: |
          RESPONSE=$(curl -s https://antbase.ai/v1/chat/completions \
            -H "Authorization: Bearer ${{ secrets.ANTBASE_API_KEY }}" \
            -H "Content-Type: application/json" \
            -d "$(jq -n \
              --arg diff "${{ steps.diff.outputs.diff }}" \
              '{
                model: "ant:fast",
                messages: [
                  {role: "system", content: "Summarize this code diff in 3-5 bullet points. Focus on what changed and why."},
                  {role: "user", content: $diff}
                ],
                max_tokens: 512,
                temperature: 0.3
              }')")
          SUMMARY=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')
          echo "summary<<EOF" >> $GITHUB_OUTPUT
          echo "$SUMMARY" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Comment on PR
        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 Summary\n\n' + `${{ steps.summary.outputs.summary }}`
            })

Configuration

For more complex workflows, use a Python or Node.js step with the SDK:

# Using Python in a workflow step
- name: AI Code Review
  run: |
    pip install openai
    python - <<'PYTHON'
    from openai import OpenAI
    import os

    client = OpenAI(
        api_key=os.environ["ANTBASE_API_KEY"],
        base_url="https://antbase.ai/v1",
    )

    with open("diff.txt") as f:
        diff = f.read()

    response = client.chat.completions.create(
        model="ant:coder",
        messages=[
            {"role": "system", "content": "Review this code diff for bugs and improvements."},
            {"role": "user", "content": diff},
        ],
        max_tokens=1024,
    )
    print(response.choices[0].message.content)
    PYTHON
  env:
    ANTBASE_API_KEY: ${{ secrets.ANTBASE_API_KEY }}

Usage Examples

Auto-generate changelog

- name: Generate changelog
  run: |
    COMMITS=$(git log --oneline v1.0.0..HEAD)
    curl -s https://antbase.ai/v1/chat/completions \
      -H "Authorization: Bearer ${{ secrets.ANTBASE_API_KEY }}" \
      -H "Content-Type: application/json" \
      -d "$(jq -n --arg commits "$COMMITS" '{
        model: "ant:fast",
        messages: [{
          role: "user",
          content: ("Generate a user-friendly changelog from these commits:\n" + $commits)
        }],
        max_tokens: 1024
      }')" | jq -r '.choices[0].message.content' > CHANGELOG_NEW.md

Virtual Models

ModelBest forNotes
ant:autoGeneral CI tasksPicks optimal model per request
ant:fastSummaries, changelogsFast and cheap for CI steps
ant:bestComplex analysisFrontier models for thorough reviews
ant:freeTesting workflowsZero cost while developing actions
ant:reasoningSecurity analysisDeep reasoning for security reviews
ant:coderCode reviewCode-optimized for diff analysis

See Virtual Models for the full list.

Troubleshooting

Secret not available in PR from fork

GitHub does not expose secrets to workflows triggered by PRs from forks. Use pull_request_target instead of pull_request if you need secrets, but be careful about running untrusted code.

Diff too large for API

Truncate the diff before sending to the API. Use head -c 10000 or filter out lock files and generated code to keep the payload manageable.