Skip to content

WF-002: GitHub Actions CI/CD

DOCUMENT CONTROL

FieldValue
WF IDWF-002
Version1.0
StatusActive

Purpose

Integrate Claude Code with GitHub Actions for automated testing and code review.

Prerequisites

  • GitHub repository
  • Anthropic API key
  • GitHub Actions enabled

Basic Setup

1. Add API Key to Secrets

  1. Go to repository Settings
  2. Secrets and variables > Actions
  3. Add ANTHROPIC_API_KEY

2. Create Workflow File

Create .github/workflows/claude-review.yml

Example Workflow

yaml
name: Claude Code Review

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
      
      - name: Install Claude Code
        run: npm install -g @anthropic-ai/claude-code
      
      - name: Review Changes
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        run: |
          git diff origin/main | claude -p "Review these changes"

Use Cases

Use CaseDescription
PR ReviewAutomated code review
Test GenerationGenerate tests for changes
Doc UpdatesUpdate documentation
Security ScanCheck for vulnerabilities

Advanced Configuration

Matrix Testing

yaml
strategy:
  matrix:
    task: [review, test, security]

Caching

yaml
- uses: actions/cache@v3
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('package-lock.json') }}

Best Practices

GitHub Actions Tips

  1. Store API keys in secrets
  2. Use caching for speed
  3. Limit scope of reviews
  4. Set timeouts

Next Steps

Based on Official Claude Code Documentation