run-gemini-cli
is a GitHub Action that integrates Gemini into your development workflow via the Gemini CLI. It acts both as an autonomous agent for critical routine coding tasks, and an on-demand collaborator you can quickly delegate work to.
Use it to perform GitHub pull request reviews, triage issues, perform code analysis and modification, and more using Gemini conversationally (e.g., @gemini-cli fix this issue
) directly inside your GitHub repositories.
- run-gemini-cli
- 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 the Gemini CLI (e.g.,
@gemini-cli /review
). - Extensible with Tools: Leverage Gemini models' tool-calling capabilities to
interact with other CLIs like the GitHub CLI (
gh
). - Customizable: Use a
GEMINI.md
file in your repository to provide project-specific instructions and context to Gemini CLI.
Get started with Gemini CLI in your repository in just a few minutes:
Obtain your API key from Google AI Studio with generous free-of-charge quotas
Store your API key as a secret named GEMINI_API_KEY
in your repository:
- Go to your repository's Settings > Secrets and variables > Actions
- Click New repository secret
- Name:
GEMINI_API_KEY
, Value: your API key
You have two options to set up a workflow:
Option A: Use setup command (Recommended)
-
Start the Gemini CLI:
gemini
-
In the chat interface, type:
/setup-github
Option B: Manually copy workflows
- Copy the pre-built workflows from the
examples/workflows
directory to your repository's.github/workflows
directory.
Pull Request Review:
- Open a pull request in your repository and wait for automatic review
- Comment
@gemini-cli /review
on an existing pull request to manually trigger a review
Issue Triage:
- Open an issue and wait for automatic triage
- Comment
@gemini-cli /triage
on existing issues to manually trigger triaging
General AI Assistance:
- In any issue or pull request, mention
@gemini-cli
followed by your request - Examples:
@gemini-cli explain this code change
@gemini-cli suggest improvements for this function
@gemini-cli help me debug this error
@gemini-cli write unit tests for this component
This action provides several pre-built workflows for different use cases. Each workflow is designed to be copied into your repository's .github/workflows
directory and customized as needed.
This action can be used to triage GitHub Issues automatically or on a schedule. For a detailed guide on how to set up the issue triage system, go to the GitHub Issue Triage workflow documentation.
This action can be used to automatically review pull requests when they are opened. For a detailed guide on how to set up the pull request review system, go to the GitHub PR Review workflow documentation.
There is a known issue that action bot may approve the PR occasionally, to avoid this situation as org owner you can restrict who can approve the PR following Code Review Limits.
This type of action can be used to invoke a general-purpose, conversational Gemini AI assistant within the pull requests and issues to perform a wide range of tasks. For a detailed guide on how to set up the general-purpose Gemini CLI workflow, go to the Gemini CLI workflow documentation.
-
prompt
: (Optional, default:You are a helpful assistant.
) A string passed to the Gemini CLI's--prompt
argument. -
settings
: (Optional) A JSON string written to.gemini/settings.json
to configure the CLI's project settings. For more details, see the documentation on settings files. -
gemini_api_key
: (Optional) The API key for the Gemini API. -
gcp_project_id
: (Optional) The Google Cloud project ID. -
gcp_location
: (Optional) The Google Cloud location. -
gcp_workload_identity_provider
: (Optional) The Google Cloud Workload Identity Provider. -
gcp_service_account
: (Optional) The Google Cloud service account email. -
use_vertex_ai
: (Optional, default:false
) A flag to indicate if Vertex AI should be used. -
use_gemini_code_assist
: (Optional, default:false
) A flag to indicate if Gemini Code Assist should be used. -
gemini_cli_version
: (Optional, default:latest
) The version of the Gemini CLI to install.
summary
: The summarized output from the Gemini CLI execution.
We recommend setting the following values as repository variables so they can be reused across all workflows. Alternatively, you can set them inline as action inputs in individual workflows or to override repository-level values.
Name | Description | Type | Required | When Required |
---|---|---|---|---|
GEMINI_CLI_VERSION |
Controls which version of the Gemini CLI is installed. | Variable | No | Pinning the CLI version |
GCP_WIF_PROVIDER |
Full resource name of the Workload Identity Provider. | Variable | No | Using Google Cloud |
GOOGLE_CLOUD_PROJECT |
Google Cloud project for inference and observability. | Variable | No | Using Google Cloud |
SERVICE_ACCOUNT_EMAIL |
Google Cloud service account email address. | Variable | No | Using Google Cloud |
GOOGLE_CLOUD_LOCATION |
Region of the Google Cloud project. | Variable | No | Using Google Cloud |
GOOGLE_GENAI_USE_VERTEXAI |
Set to true to use Vertex AI |
Variable | No | Using Vertex AI |
GOOGLE_GENAI_USE_GCA |
Set to true to use Gemini Code Assist |
Variable | No | Using Gemini Code Assist |
APP_ID |
GitHub App ID for custom authentication. | Variable | No | Using a custom GitHub App |
To add a repository variable:
- Go to your repository's Settings > Secrets and variables > Actions > New variable.
- Enter the variable name and value.
- Save.
For details about repository variables, refer to the GitHub documentation on variables.
You can set the following secrets in your repository:
Name | Description | Required | When Required |
---|---|---|---|
GEMINI_API_KEY |
Your Gemini API key from Google AI Studio. | No | You don't have a GCP project. |
APP_PRIVATE_KEY |
Private key for your GitHub App (PEM format). | No | Using a custom GitHub App. |
To add a secret:
- Go to your repository's Settings > Secrets and variables >Actions > New repository secret.
- Enter the secret name and value.
- Save.
For more information, refer to the official GitHub documentation on creating and using encrypted secrets.
This action requires authentication to both Google services (for Gemini AI) and the GitHub API.
Choose the authentication method that best fits your use case:
- Gemini API Key: The simplest method for projects that don't require Google Cloud integration
- Workload Identity Federation: The most secure method for authenticating to Google Cloud services
You can authenticate with GitHub in two ways:
- Default
GITHUB_TOKEN
: For simpler use cases, the action can use the defaultGITHUB_TOKEN
provided by the workflow. - Custom GitHub App (Recommended): For the most secure and flexible authentication, we recommend creating a custom GitHub App.
For detailed setup instructions for both Google and GitHub authentication, go to the Authentication documentation.
This action can be configured to send telemetry data (traces, metrics, and logs) to your own Google Cloud project. This allows you to monitor the performance and behavior of the Gemini CLI within your workflows, providing valuable insights for debugging and optimization.
For detailed instructions on how to set up and configure observability, go to the Observability documentation.
Create a GEMINI.md file in the root of your repository to provide project-specific context and instructions to Gemini CLI. This is useful for defining coding conventions, architectural patterns, or other guidelines the model should follow for a given repository.
Contributions are welcome! Check out the Gemini CLI Contributing Guide for more details on how to get started.