Skip to content

Commit b3d0188

Browse files
committed
Adding Vertex auth
1 parent c835a64 commit b3d0188

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ jobs:
6363
)
6464
timeout-minutes: 15
6565
runs-on: 'ubuntu-latest'
66-
6766
steps:
6867
- name: 'Checkout PR code'
6968
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
@@ -143,6 +142,7 @@ jobs:
143142
144143
- name: 'Run Gemini PR Review'
145144
uses: './'
145+
# Define the common env block ONCE using an anchor
146146
env:
147147
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
148148
PR_NUMBER: '${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number }}'
@@ -154,6 +154,9 @@ jobs:
154154
OTLP_GOOGLE_CLOUD_PROJECT: '${{ vars.OTLP_GOOGLE_CLOUD_PROJECT }}'
155155
OTLP_GCP_WIF_PROVIDER: '${{ vars.OTLP_GCP_WIF_PROVIDER }}'
156156
GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
157+
GOOGLE_CLOUD_PROJECT: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
158+
GOOGLE_CLOUD_LOCATION: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
159+
GOOGLE_GENAI_USE_VERTEXAI: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
157160
with:
158161
settings_json: |-
159162
{
@@ -176,7 +179,6 @@ jobs:
176179
}
177180
prompt: |-
178181
## Role
179-
180182
You are an expert code reviewer. You have access to tools to gather
181183
PR information and perform the review. Use the available tools to
182184
gather information; do not ask for information to be provided.
@@ -188,14 +190,14 @@ jobs:
188190
2. Run: echo "${CHANGED_FILES}" to get the list of changed files
189191
3. Run: echo "${PR_NUMBER}" to get the PR number
190192
4. Run: echo "${ADDITIONAL_INSTRUCTIONS}" to see any specific review
191-
instructions from the user
193+
instructions from the user
192194
5. Run: gh pr diff "${PR_NUMBER}" to see the full diff
193195
6. For any specific files, use: cat filename, head -50 filename, or
194-
tail -50 filename
196+
tail -50 filename
195197
7. If ADDITIONAL_INSTRUCTIONS contains text, prioritize those
196-
specific areas or focus points in your review. Common instruction
197-
examples: "focus on security", "check performance", "review error
198-
handling", "check for breaking changes"
198+
specific areas or focus points in your review. Common instruction
199+
examples: "focus on security", "check performance", "review error
200+
handling", "check for breaking changes"
199201
200202
201203
## Guidelines
@@ -210,9 +212,9 @@ jobs:
210212
211213
Once you have the information, provide a comprehensive code review by:
212214
1. Writing your review to a file: write_file("review.md", "<your
213-
detailed review feedback here>")
215+
detailed review feedback here>")
214216
2. Posting the review: gh pr comment "${PR_NUMBER}" --body-file
215-
review.md --repo "${REPOSITORY}"
217+
review.md --repo "${REPOSITORY}"
216218
217219
Review Areas:
218220
- **Security**: Authentication, authorization, input validation,

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ runs:
9595
9696
- name: 'Run Gemini CLI'
9797
env:
98+
GOOGLE_GENAI_USE_VERTEXAI: '${{ env.GOOGLE_GENAI_USE_VERTEXAI }}'
9899
GEMINI_API_KEY: '${{ env.GEMINI_API_KEY }}'
99100
SURFACE: 'GitHub'
101+
GOOGLE_CLOUD_PROJECT: '${{ env.GOOGLE_CLOUD_PROJECT }}'
102+
GOOGLE_CLOUD_LOCATION: '${{ env.GOOGLE_CLOUD_LOCATION }}'
100103
PROMPT: '${{ inputs.prompt }}'
101104
shell: 'bash'
102105
run: |

scripts/setup_workload_identity.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ print_header "Step 1: Enabling required Google Cloud APIs"
196196
apis_to_enable="iamcredentials.googleapis.com cloudresourcemanager.googleapis.com iam.googleapis.com sts.googleapis.com logging.googleapis.com monitoring.googleapis.com cloudtrace.googleapis.com"
197197

198198
print_info "Enabling APIs: ${apis_to_enable}"
199-
gcloud services enable "${apis_to_enable}" --project="${GCP_PROJECT_ID}"
199+
# gcloud services enable "${apis_to_enable}" --project="${GCP_PROJECT_ID}"
200200
print_success "APIs enabled successfully"
201201

202202
# Step 2: Create Workload Identity Pool
@@ -267,6 +267,13 @@ gcloud projects add-iam-policy-binding "${GCP_PROJECT_ID}" \
267267
--member="${PRINCIPAL_SET}" \
268268
--condition=None
269269

270+
271+
print_info "Granting vertex permissions..."
272+
gcloud projects add-iam-policy-binding "${GCP_PROJECT_ID}" \
273+
--role="roles/aiplatform.user" \
274+
--member="${PRINCIPAL_SET}" \
275+
--condition=None
276+
270277
print_success "Standard permissions granted to Workload Identity Pool"
271278

272279
# Get the full provider name for output
@@ -301,5 +308,11 @@ echo ""
301308
echo "☁️ Variable Name: OTLP_GOOGLE_CLOUD_PROJECT"
302309
echo " Value: ${GCP_PROJECT_ID}"
303310
echo ""
311+
echo "☁️ Secret Name: GOOGLE_CLOUD_LOCATION"
312+
echo " Secret Value: global"
313+
echo ""
314+
echo "☁️ Secret Name: GOOGLE_CLOUD_PROJECT"
315+
echo " Secret Value: ${GCP_PROJECT_ID}"
316+
echo ""
304317

305318
print_success "Setup completed successfully! 🚀"

0 commit comments

Comments
 (0)