Post

How to Set Up Claude Code GitHub Actions with Google Cloud Vertex AI

How to Set Up Claude Code GitHub Actions with Google Cloud Vertex AI

Transform your GitHub workflow with AI-powered assistance using Claude Code and Google Cloud’s Vertex AI - The Full Stack GCP Approach

What is Claude Code GitHub Actions?

Claude Code GitHub Actions brings Anthropic’s powerful Claude AI directly into your GitHub workflow. Simply mention @claude in any issue or pull request, and Claude will analyze your code, implement features, fix bugs, and create pull requests automatically.

Why This Setup Guide?

After successfully deploying Claude Code across multiple repositories, I discovered the key configuration patterns that ensure reliable operation. This guide shares those battle-tested configurations.

Why Google Cloud Vertex AI?

Google Cloud’s Vertex AI provides enterprise-grade infrastructure for running Claude models with:

  • Global availability across multiple regions
  • Enterprise security with VPC-SC and Private Service Connect
  • Unified AI platform for all your ML/AI workloads
  • Pay-as-you-go pricing with no upfront costs
  • Integration with other GCP services (Cloud Run, GKE, BigQuery)

Prerequisites

  • Google Cloud Project with Vertex AI enabled
  • GitHub Organization or personal repositories
  • Google Cloud CLI (gcloud) installed and authenticated
  • GitHub CLI (gh) installed and authenticated

Step 1: Deploy Claude Opus 4 in Vertex AI

  1. Navigate to Vertex AI Model Garden
  2. Select your Google Cloud project
  3. Click “Deploy” on Claude Opus 4
  4. Choose region: us-east5 (recommended for performance)
  5. Wait for deployment to complete (5-10 minutes)

Step 2: Run the Automated Setup Script

Download and run our setup script:

1
2
3
4
5
6
7
8
9
# Clone the setup repository
git clone https://github.com/AIwithTim/claude.git
cd claude

# Run setup script
./setup.sh YOUR_PROJECT_ID YOUR_GITHUB_ORG

# Example:
./setup.sh my-ai-project-123 my-github-org

This script automatically:

  • Creates a service account with proper permissions
  • Sets up Workload Identity Federation
  • Configures IAM roles for Vertex AI access
  • Provides repository-specific commands

Step 3: Add Workflow Files to Repositories

For each repository where you want Claude Code:

  1. Copy the workflow template:
    1
    
    cp claude-workflow.yml /path/to/your/repo/.github/workflows/claude.yml
    
  2. Update placeholders in the workflow file:
    • Replace YOUR_PROJECT_NUMBER with your Google Cloud project number
    • Replace YOUR_PROJECT_ID with your Google Cloud project ID
    • Replace YOUR_SERVICE_ACCOUNT with your service account name
  3. Add repository-specific Workload Identity binding:
    1
    2
    3
    4
    
    gcloud iam service-accounts add-iam-policy-binding \
      YOUR_SERVICE_ACCOUNT@YOUR_PROJECT_ID.iam.gserviceaccount.com \
      --member="principalSet://iam.googleapis.com/projects/YOUR_PROJECT_NUMBER/locations/global/workloadIdentityPools/github-actions/attribute.repository/YOUR_ORG/YOUR_REPO" \
      --role="roles/iam.workloadIdentityUser"
    

Step 4: Test Your Setup

Create a test issue in your repository:

1
@claude Please create a test file called `claude-test.txt` with the current date and time to verify the setup is working.

You should see:

  1. GitHub Actions workflow triggered
  2. Claude analyzes the request
  3. Creates a new branch with the requested file
  4. Provides a PR link in the issue comments

Advanced Configuration

Custom Model Configuration

To use different Claude models, update the workflow:

1
2
3
4
- name: Run Claude Code with Vertex AI
  uses: anthropics/claude-code-action@beta
  with:
    model: claude-3-5-sonnet@20241022  # Different model

Organization-Wide Deployment

For large organizations, consider:

  1. Template Repository: Create a template with the workflow file
  2. GitHub Apps: Use GitHub Apps API to bulk-add workflows
  3. Terraform: Automate the entire infrastructure setup

Security Considerations

  • Least Privilege: The setup uses minimal required permissions
  • Workload Identity: No service account keys stored in GitHub
  • Branch Protection: Claude creates feature branches, not direct commits
  • Audit Logs: All AI actions are logged in Google Cloud

Troubleshooting

Common Issues

Error: Permission 'iam.serviceAccounts.getAccessToken' denied

  • Solution: Run the setup script again, ensure all IAM roles are applied
  • Wait: Allow 5-10 minutes for IAM propagation

Error: Branch comparison 404

  • Solution: Add explicit repository binding as shown in Step 3
  • Check: Verify the repository name matches exactly

Workflow doesn’t trigger

  • Check: Workflow file is in .github/workflows/claude.yml
  • Verify: Issue/comment contains exact string @claude
  • Confirm: GitHub Actions are enabled for the repository

Getting Help

  • GitHub Issues: Report problems in the setup repository
  • Logs: Check GitHub Actions logs for detailed error messages
  • Google Cloud Console: Monitor Vertex AI usage and quotas

Cost Considerations

Vertex AI Pricing:

  • Claude Opus 4: ~$15 per million input tokens
  • Typical usage: $5-50/month for active repositories
  • Tip: Set billing alerts in Google Cloud Console

GitHub Actions:

  • Private repos: Consumes GitHub Actions minutes
  • Public repos: Free GitHub Actions usage

What Can Claude Do?

Once set up, Claude can help with:

Code Development

  • Feature Implementation: @claude add user authentication to this Express app
  • Bug Fixes: @claude fix the memory leak in this function
  • Code Review: @claude review this PR for security issues

Documentation

  • README Updates: @claude update the README with installation instructions
  • API Documentation: @claude generate OpenAPI spec for these endpoints
  • Code Comments: @claude add JSDoc comments to these functions

Testing

  • Unit Tests: @claude write tests for this component
  • Integration Tests: @claude create E2E tests for the login flow
  • Test Fixes: @claude fix these failing tests

Analysis

  • Architecture Review: @claude analyze this codebase structure
  • Performance Audit: @claude identify performance bottlenecks
  • Security Scan: @claude check for security vulnerabilities

Best Practices

  1. Be Specific: Detailed requests get better results
  2. Provide Context: Mention relevant files or technologies
  3. Iterative Requests: Break complex tasks into smaller steps
  4. Review Changes: Always review Claude’s code before merging
  5. Set Expectations: Claude creates feature branches, not direct merges

Real-World Examples

Here are successful deployments:

Example 1: E-commerce Platform

  • Repositories: 15 microservices
  • Usage: Feature development, bug fixes, documentation
  • Result: 40% faster development cycle

Example 2: Open Source Project

  • Repositories: 5 core repos + documentation
  • Usage: Community issue resolution, code reviews
  • Result: Improved contributor onboarding

Example 3: Startup MVP

  • Repositories: Frontend + Backend + Mobile
  • Usage: Rapid prototyping, testing, refactoring
  • Result: MVP delivered 60% faster

Conclusion

Claude Code GitHub Actions transforms how teams interact with AI in their development workflow. The setup requires careful attention to IAM permissions and Workload Identity Federation, but once configured, provides a powerful AI assistant directly in your GitHub issues and pull requests.

The investment in setup pays dividends in:

  • Faster Development: AI-assisted coding and reviews
  • Better Documentation: Automated documentation generation
  • Improved Code Quality: AI-powered analysis and suggestions
  • Enhanced Learning: AI explanations of complex code

Start with a test repository, verify the setup works, then gradually roll out to your entire organization.


Ready to get started? Download the setup files and follow this guide to transform your GitHub workflow with AI assistance.

Have questions or success stories? Share them in the repository discussions or reach out @AIwithTim!

This post is licensed under CC BY 4.0 by the author.