Gemini CLI GitHub Actions: Google Cloud's Native AI for Your DevOps Workflow
Integrate Google’s Gemini AI into your development workflow for autonomous coding, issue triage, and pull request reviews
Overview
run-gemini-cli is a GitHub Action that brings the power of Google’s Gemini AI directly into your GitHub repositories. It acts as both an autonomous agent for critical routine coding tasks and an on-demand collaborator you can quickly delegate work to.
After testing both Claude and Gemini GitHub Actions extensively, I’ve found Gemini CLI offers unique advantages, especially for teams already in the Google ecosystem. Here’s everything you need to know to get started.
Why Gemini CLI?
Google Cloud Native Advantages
- Google Cloud Integration: Seamlessly works with GCP services
- Free Tier: Generous free quotas from Google AI Studio
- Dual Deployment Options:
- Quick start with API keys
- Enterprise-grade with Vertex AI integration
- Full Stack GCP: Part of Google’s comprehensive AI ecosystem
- Built-in Tools: Native GitHub CLI integration for advanced operations
- Cost-Effective: Significantly cheaper for high-volume usage
Features
- Automation: Trigger workflows based on events (e.g., issue opening) or schedules (e.g., nightly)
- On-demand Collaboration: Trigger workflows in issue and pull request comments by mentioning
@gemini-cli - Extensible with Tools: Leverage Gemini’s tool-calling capabilities to interact with CLIs like GitHub CLI (
gh) - Customizable: Use a
GEMINI.mdfile for project-specific instructions
Quick Start Guide
Step 1: Get Your Gemini API Key
- Visit Google AI Studio
- Click “Create API Key”
- Copy your key (starts with
AIza...)
Step 2: Add as GitHub Secret
- Go to your repository’s Settings > Secrets and variables > Actions
- Click New repository secret
- Name:
GEMINI_API_KEY - Value: Your API key from Step 1
Step 3: Setup Workflows
Option A: Automated Setup (Recommended)
1
2
3
4
5
6
7
8
# Install Gemini CLI globally
npm install -g @google/gemini-cli
# Start the CLI
gemini
# In the chat interface, type:
/setup-github
This automatically creates optimized workflow files for your repository.
Option B: Manual Setup
Create .github/workflows/gemini.yml:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
name: Gemini CLI Assistant
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
pull_request:
types: [opened, edited, synchronize]
pull_request_review_comment:
types: [created, edited]
jobs:
gemini-assist:
if: contains(github.event.comment.body || github.event.issue.body || github.event.pull_request.body, '@gemini-cli')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Gemini CLI
uses: google-github-actions/run-gemini-cli@v1
with:
api_key: $
github_token: $
model: gemini-1.5-flash # or gemini-1.5-pro for complex tasks
Step 4: Test Your Setup
Create a test issue with:
1
@gemini-cli create a simple Python script that prints "Hello from Gemini!"
Within seconds, Gemini will:
- Analyze your request
- Create a new branch
- Generate the code
- Open a pull request
Workflow Examples
Pull Request Review
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
name: Automated PR Review
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Gemini Review
uses: google-github-actions/run-gemini-cli@v1
with:
api_key: $
github_token: $
command: |
Review this pull request for:
- Code quality and best practices
- Security vulnerabilities
- Performance implications
- Test coverage
Issue Triage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
name: Issue Triage
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
steps:
- name: Triage with Gemini
uses: google-github-actions/run-gemini-cli@v1
with:
api_key: $
github_token: $
command: |
Triage this issue:
- Add appropriate labels
- Suggest priority (P0-P3)
- Identify related issues
- Propose initial solution approach
Scheduled Documentation Updates
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
name: Weekly Doc Updates
on:
schedule:
- cron: '0 9 * * 1' # Every Monday at 9 AM
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update Documentation
uses: google-github-actions/run-gemini-cli@v1
with:
api_key: $
github_token: $
command: |
Update README.md with:
- Any new dependencies
- Updated API documentation
- Recent configuration changes
Advanced Configuration
Custom Instructions with GEMINI.md
Create a GEMINI.md file in your repository root:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Project Context for Gemini
## Tech Stack
- Frontend: React with TypeScript
- Backend: Node.js with Express
- Database: PostgreSQL
- Testing: Jest and Cypress
## Coding Standards
- Use functional components with hooks
- Follow ESLint configuration
- Write tests for all new features
- Use conventional commits
## Project-Specific Rules
- Never modify the database schema without migration files
- All API endpoints must have OpenAPI documentation
- Performance: Keep bundle size under 200KB
Model Selection
Choose the right model for your needs:
1
2
3
4
5
6
7
8
# For simple tasks (faster, cheaper)
model: gemini-1.5-flash
# For complex analysis (slower, more capable)
model: gemini-1.5-pro
# For vision tasks (analyzing screenshots/diagrams)
model: gemini-1.5-flash-vision
Tool Integration
Enable GitHub CLI for advanced operations:
1
2
3
4
5
6
7
8
9
10
- name: Gemini with GitHub CLI
uses: google-github-actions/run-gemini-cli@v1
with:
api_key: $
github_token: $
enable_tools: true
tools:
- github-cli
- npm
- python
Real-World Use Cases
1. Automated Bug Fixes
1
2
@gemini-cli The login button is not working on mobile devices.
The error appears in LoginComponent.tsx line 45. Please fix this issue.
Gemini will:
- Analyze the component
- Identify the mobile-specific issue
- Create a fix
- Add responsive tests
2. Code Generation
1
2
3
4
5
@gemini-cli Create a REST API endpoint for user profile management with:
- GET /api/profile/:id
- PUT /api/profile/:id
- Validation middleware
- Unit tests
3. Performance Optimization
1
2
3
4
@gemini-cli Analyze the Dashboard component for performance issues and optimize:
- Reduce re-renders
- Implement lazy loading
- Add memoization where appropriate
4. Security Audit
1
2
3
4
5
6
7
@gemini-cli /security-audit
Perform a security audit of this PR checking for:
- SQL injection vulnerabilities
- XSS attacks
- Authentication bypasses
- Sensitive data exposure
Comparison: Gemini vs Claude GitHub Actions
| Feature | Gemini CLI | Claude Code |
|---|---|---|
| Setup Time | 5 minutes | 30+ minutes |
| Requirements | API key only | Google Cloud + Vertex AI |
| Free Tier | Generous | Limited |
| Cost | ~$1.25/million tokens | ~$15/million tokens |
| Response Time | 2-5 seconds | 5-10 seconds |
| Code Quality | Excellent | Excellent |
| Documentation | Good | Excellent |
| Tool Integration | Native | Via MCP |
Best Practices
1. Clear Instructions
1
2
❌ @gemini-cli fix this
✅ @gemini-cli Fix the TypeError in utils/parser.js line 23 when parsing null values
2. Iterative Development
Break complex tasks into smaller requests:
1
2
3
@gemini-cli Step 1: Create the database schema for a blog system
@gemini-cli Step 2: Add the API endpoints for CRUD operations
@gemini-cli Step 3: Create the frontend components
3. Review Before Merge
Always review Gemini’s changes:
- Check for security issues
- Verify business logic
- Ensure code style compliance
- Run tests locally
4. Use Branch Protection
Configure branch protection rules:
- Require PR reviews
- Run CI/CD checks
- Prevent direct commits to main
Cost Optimization
Free Tier Limits
- Gemini 1.5 Flash: 15 RPM, 1 million TPM, 1,500 RPD
- Gemini 1.5 Pro: 2 RPM, 32,000 TPM, 50 RPD
Tips to Stay Within Limits
- Use
gemini-1.5-flashfor routine tasks - Batch similar requests
- Cache responses for repeated queries
- Set up quotas and alerts
Troubleshooting
Common Issues and Solutions
Issue: Workflow doesn’t trigger
- Ensure
@gemini-cliis mentioned exactly - Check workflow file syntax
- Verify GitHub Actions is enabled
Issue: API quota exceeded
- Switch to
gemini-1.5-flash - Implement rate limiting
- Consider paid tier
Issue: Incorrect code generation
- Add project context in
GEMINI.md - Be more specific in requests
- Provide example code
Conclusion
Gemini CLI GitHub Actions offers the fastest path to AI-assisted development with minimal setup and generous free tier. It’s perfect for:
- Individual developers wanting AI assistance
- Open source projects needing automation
- Startups optimizing development speed
- Teams already using Google Cloud
The combination of ease of setup, cost-effectiveness, and powerful capabilities makes Gemini CLI an excellent choice for integrating AI into your GitHub workflow.
Get Started Today!
Questions? Found a cool use case? Share in the comments or reach out @AIwithTim!