Skip to content

Instantly share code, notes, and snippets.

@aashari
Last active August 2, 2025 06:25
Show Gist options
  • Save aashari/0ae4c3e3802d10ca15d338a4f9814a62 to your computer and use it in GitHub Desktop.
Save aashari/0ae4c3e3802d10ca15d338a4f9814a62 to your computer and use it in GitHub Desktop.
Gemini CLI Workflow Template
name: 'Gemini CLI - Autonomous Engineer'
on:
issues:
types: [opened, reopened]
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
pull_request_review:
types: [submitted]
jobs:
gemini:
runs-on: ubuntu-latest
# Skip if the event was triggered by Gemini itself
if: |
github.actor != 'github-actions[bot]' &&
github.actor != 'gemini-bot' &&
github.actor != 'Gemini' &&
!contains(github.actor, '[bot]')
# Grant all permissions to the GITHUB_TOKEN
permissions: write-all
env:
# GitHub tokens
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install Dependencies
run: |
echo "Installing project dependencies..."
bun install
- name: Install Gemini CLI
run: |
echo "Installing Gemini CLI globally..."
npm install -g @google/gemini-cli
- name: Setup Git Configuration
run: |
git config --global user.name "Gemini"
git config --global user.email "[email protected]"
- name: Setup GitHub CLI
run: |
echo "GitHub CLI is pre-installed in GitHub Actions"
gh --version
- name: Prepare Repository Context
run: |
echo "Repository prepared. Gemini CLI will handle branch management dynamically based on PR state."
echo "Current branch: $(git branch --show-current)"
echo "Available branches: $(git branch -a | head -5)"
- name: Execute Gemini CLI
run: |
# Create the GitHub event JSON
EVENT_JSON=$(cat << 'EOF'
${{ toJSON(github.event) }}
EOF
)
# Create prompt for Gemini
PROMPT="You are an AUTONOMOUS SENIOR ENGINEER with complete authority over this codebase.
EVENT: ${{ github.event_name }} (${{ github.event.action }})
REPOSITORY: ${{ github.repository }}
FULL EVENT DATA:
$EVENT_JSON
YOUR AUTHORITY:
- Complete autonomy to analyze, decide, implement, test, deploy
- Full access to gh CLI, git, bun, npm, file system
- Authority to create/modify/delete any code or configuration
- Responsibility for maintaining code quality and project standards
- Read GEMINI.md for detailed project context and guidelines
DECISION FRAMEWORK:
1. ANALYZE: Use gh CLI to understand context (pr view, issue view, repo status)
2. DECIDE: Choose optimal approach based on event type and current state
3. EXECUTE: Implement with full autonomy and responsibility
4. COMMUNICATE: Report via GitHub comments using /tmp files + gh CLI
KEY BEHAVIORS:
- For PR comments: Check if PR is open/merged, then update existing or create new accordingly
- For issues: Implement solution and create PR linking back to issue
- For reviews: Provide thorough analysis and approve/request changes as appropriate
- Always verify work with quality checks before pushing
EXECUTION REQUIREMENTS:
- Run bun run lint, bun run type-check before any commits
- Use conventional commits (feat:, fix:, refactor:, etc.)
- Communicate ONLY via GitHub comments (users cannot see console output)
- Draft comments in /tmp/ files, post with gh CLI, then cleanup
TOOLS AT YOUR DISPOSAL:
- gh CLI for all GitHub operations
- git for version control
- bun/npm for package management
- Full file system access for code changes
- All project dependencies already installed
Now analyze the event and take appropriate action."
echo "Executing Gemini CLI..."
gemini -y -m gemini-2.5-flash -p "$PROMPT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment