WF-002: GitHub Actions CI/CD
DOCUMENT CONTROL
| Field | Value |
|---|---|
| WF ID | WF-002 |
| Version | 1.0 |
| Status | Active |
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
- Go to repository Settings
- Secrets and variables > Actions
- 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 Case | Description |
|---|---|
| PR Review | Automated code review |
| Test Generation | Generate tests for changes |
| Doc Updates | Update documentation |
| Security Scan | Check 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
- Store API keys in secrets
- Use caching for speed
- Limit scope of reviews
- Set timeouts