Skip to content

Commit 98a1cf8

Browse files
vivekkairiVivek Kairi
andauthored
Add GOOGLE_API_KEY variable (#201)
Add GOOGLE_API_KEY for Vertex AI Express Mode --------- Co-authored-by: Vivek Kairi <vivek@zerodhafundhouse.com>
1 parent 2fa6ffe commit 98a1cf8

7 files changed

Lines changed: 56 additions & 10 deletions

File tree

.github/workflows/gemini-cli.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ jobs:
125125
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
126126
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
127127
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
128+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
128129
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
129130
settings: |-
130131
{

.github/workflows/gemini-issue-automated-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
8888
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
8989
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
90+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
9091
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
9192
settings: |-
9293
{

.github/workflows/gemini-issue-scheduled-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ jobs:
9595
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
9696
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
9797
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
98+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
9899
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
99100
settings: |-
100101
{

.github/workflows/gemini-pr-review.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ jobs:
169169
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
170170
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
171171
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
172+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
172173
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
173174
settings: |-
174175
{

README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,19 @@ Use it to perform GitHub pull request reviews, triage issues, perform code analy
4545
Get started with Gemini CLI in your repository in just a few minutes:
4646

4747
### 1. Get a Gemini API Key
48+
4849
Obtain your API key from [Google AI Studio] with generous free-of-charge quotas
4950

5051
### 2. Add it as a GitHub Secret
52+
5153
Store your API key as a secret named `GEMINI_API_KEY` in your repository:
54+
5255
- Go to your repository's **Settings > Secrets and variables > Actions**
5356
- Click **New repository secret**
5457
- Name: `GEMINI_API_KEY`, Value: your API key
5558

5659
### 3. Update your .gitignore
60+
5761
Add the following entries to your `.gitignore` file:
5862

5963
```gitignore
@@ -65,9 +69,11 @@ gha-creds-*.json
6569
```
6670

6771
### 4. Choose a Workflow
72+
6873
You have two options to set up a workflow:
6974

7075
**Option A: Use setup command (Recommended)**
76+
7177
1. Start the Gemini CLI in your terminal:
7278

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

8389
**Option B: Manually copy workflows**
90+
8491
1. Copy the pre-built workflows from the [`examples/workflows`](./examples/workflows) directory to your repository's `.github/workflows` directory.
8592

8693
### 5. Try it out!
8794

8895
**Pull Request Review:**
96+
8997
- Open a pull request in your repository and wait for automatic review
9098
- Comment `@gemini-cli /review` on an existing pull request to manually trigger a review
9199

92100
**Issue Triage:**
101+
93102
- Open an issue and wait for automatic triage
94103
- Comment `@gemini-cli /triage` on existing issues to manually trigger triaging
95104

96105
**General AI Assistance:**
106+
97107
- In any issue or pull request, mention `@gemini-cli` followed by your request
98108
- Examples:
99109
- `@gemini-cli explain this code change`
@@ -117,7 +127,7 @@ This action can be used to automatically review pull requests when they are
117127
opened. For a detailed guide on how to set up the pull request review system,
118128
go to the [GitHub PR Review workflow documentation](./examples/workflows/pr-review).
119129

120-
There is a [known issue](https://github.com/google-github-actions/run-gemini-cli/issues/169) that action bot may approve the PR occasionally,
130+
There is a [known issue](https://github.com/google-github-actions/run-gemini-cli/issues/169) that action bot may approve the PR occasionally,
121131
to avoid this situation as org owner you can restrict who can approve the PR following
122132
[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).
123133

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

154164
- <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.
155165

166+
- <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.
167+
156168

157169
<!-- END_AUTOGEN_INPUTS -->
158170

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

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

177+
- `error`: The error output from the Gemini CLI execution, if any.
178+
165179

166180
<!-- END_AUTOGEN_OUTPUTS -->
167181

@@ -180,22 +194,23 @@ We recommend setting the following values as repository variables so they can be
180194
| `GOOGLE_GENAI_USE_GCA` | Set to `true` to use Gemini Code Assist | Variable | No | Using Gemini Code Assist |
181195
| `APP_ID` | GitHub App ID for custom authentication. | Variable | No | Using a custom GitHub App |
182196

183-
184197
To add a repository variable:
185-
1) Go to your repository's **Settings > Secrets and variables > Actions > New variable**.
186-
2) Enter the variable name and value.
187-
3) Save.
198+
199+
1. Go to your repository's **Settings > Secrets and variables > Actions > New variable**.
200+
2. Enter the variable name and value.
201+
3. Save.
188202

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

191205
### Secrets
192206

193207
You can set the following secrets in your repository:
194208

195-
| Name | Description | Required | When Required |
196-
| ----------------- | --------------------------------------------- | -------- | ----------------------------- |
197-
| `GEMINI_API_KEY` | Your Gemini API key from Google AI Studio. | No | You don't have a GCP project. |
198-
| `APP_PRIVATE_KEY` | Private key for your GitHub App (PEM format). | No | Using a custom GitHub App. |
209+
| Name | Description | Required | When Required |
210+
| ----------------- | --------------------------------------------- | -------- | ------------------------------------- |
211+
| `GEMINI_API_KEY` | Your Gemini API key from Google AI Studio. | No | You don't have a GCP project. |
212+
| `APP_PRIVATE_KEY` | Private key for your GitHub App (PEM format). | No | Using a custom GitHub App. |
213+
| `GOOGLE_API_KEY` | Your Google API Key to use with Vertex AI. | No | You have a express Vertex AI account. |
199214

200215
To add a secret:
201216

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ inputs:
5555
description: 'The version of the Gemini CLI to install.'
5656
required: false
5757
default: 'latest'
58+
google_api_key:
59+
description: 'The Vertex AI API key to use with Gemini.'
60+
required: false
5861

5962
outputs:
6063
summary:
@@ -191,6 +194,7 @@ runs:
191194
GOOGLE_CLOUD_PROJECT: '${{ inputs.gcp_project_id }}'
192195
GOOGLE_CLOUD_LOCATION: '${{ inputs.gcp_location }}'
193196
GOOGLE_GENAI_USE_VERTEXAI: '${{ inputs.use_vertex_ai }}'
197+
GOOGLE_API_KEY: '${{ inputs.google_api_key }}'
194198
GOOGLE_GENAI_USE_GCA: '${{ inputs.use_gemini_code_assist }}'
195199
GOOGLE_CLOUD_ACCESS_TOKEN: '${{steps.auth.outputs.access_token}}'
196200
PROMPT: '${{ inputs.prompt }}'

docs/authentication.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,30 @@ This is the simplest method and is suitable for projects that do not require Goo
5656
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
5757
```
5858
59-
### Method 2: Authenticating with Google Cloud
59+
### Method 2: Authenticating with a Vertex AI API Key
60+
61+
This method is used for quick setup using Vertex AI through Google Cloud Console
62+
63+
#### Prerequisites
64+
65+
- A Vertex AI API key from Google Cloud Console
66+
67+
#### Setup
68+
69+
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)
70+
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`.
71+
72+
#### Example
73+
74+
```yaml
75+
- uses: 'google-github-actions/run-gemini-cli@v0'
76+
with:
77+
prompt: |-
78+
Explain this code
79+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
80+
```
81+
82+
### Method 3: Authenticating with Google Cloud
6083

6184
**[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:
6285

0 commit comments

Comments
 (0)