Bring Google Gemini into Your GitHub Workflow: A Practical, No-Hype Guide

Written for junior-college graduates and busy professionals who want working code, not buzzwords.


Why Let AI Live in Your Repository?

Picture this Monday morning:

  • You open a pull request (PR). No one reviews it for hours.
  • Issues pile up with titles like “help” and “it’s broken.”
  • You need unit tests but the deadline is tomorrow.

run-gemini-cli is an open-source GitHub Action that drops Google Gemini directly into your repo.
It can:

  • Review every PR the moment it is opened.
  • Triage issues by adding labels and next-step suggestions.
  • Answer questions on demand—just type @gemini-cli explain this function in any comment.

The rest of this article shows, step by step, how to install it and how to teach it to follow your team’s style.
No marketing fluff. No paid extras. All commands and settings come straight from the official README.


What You Will Achieve in 20 Minutes

Goal Outcome
Install the Action AI starts reviewing PRs automatically.
Add a 3-line prompt AI writes unit tests in your style.
Create one file (GEMINI.md) AI remembers your coding rules forever.

A Quick Look at the Features

Feature Trigger What the AI Does
Automated PR Review pull_request: opened or comment /review Line-by-line feedback, style checks, bug risks.
Issue Triage issues: opened or comment /triage Adds labels (bug, enhancement, question) and a short action plan.
On-Demand Assistant Any comment with @gemini-cli Answers questions, refactors code, writes tests, explains errors.
Scheduled Tasks Cron expression Nightly static analysis, weekly summary, etc.

Four-Step Setup (Copy-Paste Friendly)

Step 1 – Get a Free Gemini API Key

  1. Visit Google AI Studio.
  2. Click Create API KeyCopy.
  3. Done. No credit card for the free tier.

Step 2 – Lock the Key in GitHub

  1. Open your repo → Settings → Secrets and variables → Actions.
  2. New repository secret

    • Name: GEMINI_API_KEY
    • Value: paste the key
  3. Save.

Step 3 – Pick a Workflow

Two equally valid paths:

  • Recommended – Copy ready-made files

    1. Go to the examples/workflows folder in the Action’s repo.
    2. Copy the YAML files you need into your own .github/workflows directory.
  • Interactive – Use the CLI setup

    1. In any terminal with Node installed:

      npx gemini
      
    2. In the chat prompt, type

      /setup-github
      
    3. Follow the on-screen steps; the CLI pushes the correct workflow files for you.

Step 4 – First Test

  • Open a new PR (change one line of code).
  • Within 60 seconds, a review comment from github-actions[bot] appears.
  • Or open an issue and comment @gemini-cli /triage.
    The bot replies with labels and a short next-step message.

Deep Dive: Teaching the AI Your House Rules

Create a file named GEMINI.md in the repository root.
Treat it like a short onboarding document for a new teammate.

# Project Guidelines
- Indent with 2 spaces, never tabs.  
- Function names are camelCase; constants are UPPER_SNAKE_CASE.  
- Every public function needs JSDoc comments.  
- Prefer `const` and `let` over `var`.

The AI reads GEMINI.md before every run, so future reviews, tests, and explanations follow these rules automatically.


Ready-Made Workflow Templates

Copy any of the following files into .github/workflows and push.
No other changes are required if you completed the four-step setup.

1) Automatic PR Review

# .github/workflows/pr-review.yml
name: Gemini PR Review
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: google-gemini/run-gemini-cli@main
        with:
          gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
          prompt: "You are a senior code reviewer. Provide line-by-line feedback."

2) Issue Triage

# .github/workflows/issue-triage.yml
name: Gemini Issue Triage
on:
  issues:
    types: [opened, edited]

jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
      - uses: google-gemini/run-gemini-cli@main
        with:
          gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
          prompt: |
            Read the issue title and body, then add one of the labels:
            bug, enhancement, question. Provide a short next step for the author.

3) On-Demand Assistant

# .github/workflows/gemini-cli.yml
name: Gemini On-Demand Assistant
on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

jobs:
  chat:
    if: contains(github.event.comment.body, '@gemini-cli')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: google-gemini/run-gemini-cli@main
        with:
          gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
          prompt: ${{ github.event.comment.body }}

Input Reference (Quick Lookup)

YAML Key Default When to Change
prompt “You are a helpful assistant.” Supply persona or project rules.
settings none Provide a JSON string to write into .gemini/settings.json for advanced CLI options.
use_vertex_ai false Set true if your company uses Google Cloud Vertex AI instead of the free key.
gemini_cli_version latest Pin to a specific release tag if you need stability (e.g., v1.2.3).

Repository Variables vs Secrets

Type Example Name Purpose
Secret GEMINI_API_KEY Private credentials (never shown in logs).
Variable GEMINI_CLI_VERSION Public, reusable settings (visible in workflow files).

Set variables under Settings → Secrets and variables → Variables.
Typical variables you might add:

  • GEMINI_CLI_VERSION: v1.2.3
  • GOOGLE_CLOUD_PROJECT: my-gcp-project-id (if you switch to Vertex AI)

Authentication Choices

You only need one of the following:

  1. Gemini API Key (the free path we used in the four-step setup).
  2. Workload Identity Federation (Google Cloud enterprise accounts).

    • Requires extra variables: GOOGLE_CLOUD_PROJECT, GCP_WIF_PROVIDER, SERVICE_ACCOUNT_EMAIL.

For GitHub, the Action works out-of-the-box with the default GITHUB_TOKEN.
Large teams can create a dedicated GitHub App for granular permissions; the README links to a separate authentication doc if you need it.


Observability (Optional but Useful)

If you already use Google Cloud, you can send traces and logs to your own project.
Set these variables:

env:
  GOOGLE_CLOUD_PROJECT: my-project
  GOOGLE_CLOUD_LOCATION: us-central1

The Action will automatically export metrics.
No extra cost unless you enable additional Cloud Logging retention.


Troubleshooting Checklist

Symptom Likely Cause Fix
Workflow never starts YAML file in wrong folder Move to .github/workflows/*.yml
Bot leaves no comment Missing API key Check Settings → Secrets → GEMINI_API_KEY
403 error Restricted Actions Go to Settings → Actions → Allow all actions
Garbled output Non-UTF-8 source files Save all code as UTF-8

Real-Life Mini FAQ

Q: Does the AI store my source code?
A: No. GitHub’s runner loads the code into RAM, sends only the diff to Google, and discards it after the run.

Q: Can I run this on a private enterprise server?
A: Yes. If your GitHub Enterprise Server can reach the internet, the Action works the same way.

Q: What if I exceed the free quota?
A: Google will return HTTP 429. Add billing to your Google Cloud project and switch to Vertex AI by flipping use_vertex_ai: true.


Next Steps

  1. Pick one workflow file, commit it, and watch your first AI review appear.
  2. Edit GEMINI.md with your style rules so every future suggestion is on-brand.
  3. Encourage teammates to tag @gemini-cli for quick questions; the learning curve is zero.

You have now automated the tedious parts of code review and issue triage without leaving GitHub.
Spend the reclaimed time on architecture, product, or simply an earlier Friday evening.