Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/gemini-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ jobs:
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
settings: |-
{
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gemini-issue-automated-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
settings: |-
{
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gemini-issue-scheduled-triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
settings: |-
{
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gemini-pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ jobs:
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
settings: |-
{
Expand Down
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ Use it to perform GitHub pull request reviews, triage issues, perform code analy
Get started with Gemini CLI in your repository in just a few minutes:

### 1. Get a Gemini API Key

Obtain your API key from [Google AI Studio] with generous free-of-charge quotas

### 2. Add it as a GitHub Secret

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

### 3. Update your .gitignore

Add the following entries to your `.gitignore` file:

```gitignore
Expand All @@ -65,9 +69,11 @@ gha-creds-*.json
```

### 4. Choose a Workflow

You have two options to set up a workflow:

**Option A: Use setup command (Recommended)**

1. Start the Gemini CLI in your terminal:

```shell
Expand All @@ -81,19 +87,23 @@ You have two options to set up a workflow:
```

**Option B: Manually copy workflows**

1. Copy the pre-built workflows from the [`examples/workflows`](./examples/workflows) directory to your repository's `.github/workflows` directory.

### 5. Try it out!

**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`
Expand All @@ -117,7 +127,7 @@ 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](./examples/workflows/pr-review).

There is a [known issue](https://github.com/google-github-actions/run-gemini-cli/issues/169) that action bot may approve the PR occasionally,
There is a [known issue](https://github.com/google-github-actions/run-gemini-cli/issues/169) 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](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/managing-repository-settings/managing-pull-request-reviews-in-your-repository#enabling-code-review-limits).

Expand Down Expand Up @@ -153,6 +163,8 @@ go to the [Gemini CLI workflow documentation](./examples/workflows/gemini-cli).

- <a name="gemini_cli_version"></a><a href="#user-content-gemini_cli_version"><code>gemini_cli_version</code></a>: _(Optional, default: `latest`)_ The version of the Gemini CLI to install.

- <a name="google_api_key"></a><a href="#user-content-google_api_key"><code>google_api_key</code></a>: _(Optional)_ The Vertex AI API key to use with Gemini.


<!-- END_AUTOGEN_INPUTS -->

Expand All @@ -162,6 +174,8 @@ go to the [Gemini CLI workflow documentation](./examples/workflows/gemini-cli).

- `summary`: The summarized output from the Gemini CLI execution.

- `error`: The error output from the Gemini CLI execution, if any.


<!-- END_AUTOGEN_OUTPUTS -->

Expand All @@ -180,22 +194,23 @@ We recommend setting the following values as repository variables so they can be
| `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:
1) Go to your repository's **Settings > Secrets and variables > Actions > New variable**.
2) Enter the variable name and value.
3) Save.

1. Go to your repository's **Settings > Secrets and variables > Actions > New variable**.
2. Enter the variable name and value.
3. Save.

For details about repository variables, refer to the [GitHub documentation on variables][variables].

### Secrets

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. |
| 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. |
| `GOOGLE_API_KEY` | Your Google API Key to use with Vertex AI. | No | You have a express Vertex AI account. |

To add a secret:

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ inputs:
description: 'The version of the Gemini CLI to install.'
required: false
default: 'latest'
google_api_key:
description: 'The Vertex AI API key to use with Gemini.'
required: false

outputs:
summary:
Expand Down Expand Up @@ -201,6 +204,7 @@ runs:
GOOGLE_CLOUD_PROJECT: '${{ inputs.gcp_project_id }}'
GOOGLE_CLOUD_LOCATION: '${{ inputs.gcp_location }}'
GOOGLE_GENAI_USE_VERTEXAI: '${{ inputs.use_vertex_ai }}'
GOOGLE_API_KEY: '${{ inputs.google_api_key }}'
GOOGLE_GENAI_USE_GCA: '${{ inputs.use_gemini_code_assist }}'
GOOGLE_CLOUD_ACCESS_TOKEN: '${{steps.auth.outputs.access_token}}'
PROMPT: '${{ inputs.prompt }}'
Expand Down
25 changes: 24 additions & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,30 @@ This is the simplest method and is suitable for projects that do not require Goo
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
```

### Method 2: Authenticating with Google Cloud
### Method 2: Authenticating with a Vertex AI API Key

This method is used for quick setup using Vertex AI through Google Cloud Console

#### Prerequisites

- A Vertex AI API key from Google Cloud Console

#### Setup

1. **Create an API Key**: Obtain your Google Cloud [API key](https://cloud.google.com/vertex-ai/generative-ai/docs/start/api-keys?usertype=newuser)
2. **Add to GitHub Secrets**: In your GitHub repository, go to **Settings > Secrets and variables > Actions** and add a new repository secret with the name `GOOGLE_API_KEY` and paste your key as the value and create new variable with the name `GOOGLE_GENAI_USE_VERTEXAI` and set value as `true`.

#### Example

```yaml
- uses: 'google-github-actions/run-gemini-cli@v0'
with:
prompt: |-
Explain this code
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
```

### Method 3: Authenticating with Google Cloud

**[Workload Identity Federation](https://cloud.google.com/iam/docs/workload-identity-federation)** is Google Cloud's preferred, keyless authentication method for GitHub Actions. It provides:

Expand Down
Loading