You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: action.yml
+35-1Lines changed: 35 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ runs:
134
134
fi
135
135
136
136
if [[ ${auth_methods} -gt 1 ]]; then
137
-
warn "Multiple authentication methods provided. Please use only one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
137
+
echo "::notice title=Authentication priority::Multiple authentication methods provided. The action will prioritize them in the following order: 1. Workload Identity Federation, 2. Vertex AI API Key, 3. Gemini API Key. Conflicting environment variables will be unset for the CLI."
138
138
fi
139
139
140
140
# Validate Workload Identity Federation inputs
@@ -260,6 +260,20 @@ runs:
260
260
echo "Error: Gemini CLI not found in PATH"
261
261
exit 1
262
262
fi
263
+
264
+
# Sanitize authentication environment variables to avoid conflicts when installing extensions.
265
+
if [[ -n "${GOOGLE_CLOUD_ACCESS_TOKEN:-}" ]]; then
266
+
unset GEMINI_API_KEY
267
+
unset GOOGLE_API_KEY
268
+
elif [[ "${GOOGLE_GENAI_USE_VERTEXAI:-false}" == "true" && -n "${GOOGLE_API_KEY:-}" ]]; then
269
+
unset GEMINI_API_KEY
270
+
elif [[ -n "${GEMINI_API_KEY:-}" ]]; then
271
+
export GOOGLE_GENAI_USE_VERTEXAI="false"
272
+
export GOOGLE_GENAI_USE_GCA="false"
273
+
unset GOOGLE_API_KEY
274
+
unset GOOGLE_CLOUD_ACCESS_TOKEN
275
+
fi
276
+
263
277
if [[ -n "${EXTENSIONS}" ]]; then
264
278
echo "Installing Gemini CLI extensions:"
265
279
echo "${EXTENSIONS}" | jq -r '.[]' | while IFS= read -r extension; do
@@ -289,6 +303,26 @@ runs:
289
303
# Keep track of whether we've failed
290
304
FAILED=false
291
305
306
+
# Sanitize authentication environment variables to avoid conflicts.
307
+
# Priority:
308
+
# 1. Workload Identity Federation (use_vertex_ai or use_gemini_code_assist with access token)
309
+
# 2. Vertex AI API Key (use_vertex_ai with google_api_key)
310
+
# 3. Gemini API Key (gemini_api_key)
311
+
if [[ -n "${GOOGLE_CLOUD_ACCESS_TOKEN:-}" ]]; then
312
+
echo "Using Workload Identity Federation; unsetting conflicting API keys."
313
+
unset GEMINI_API_KEY
314
+
unset GOOGLE_API_KEY
315
+
elif [[ "${GOOGLE_GENAI_USE_VERTEXAI:-false}" == "true" && -n "${GOOGLE_API_KEY:-}" ]]; then
316
+
echo "Using Vertex AI API Key; unsetting conflicting Gemini API key."
317
+
unset GEMINI_API_KEY
318
+
elif [[ -n "${GEMINI_API_KEY:-}" ]]; then
319
+
echo "Using Gemini API Key; ensuring Vertex AI and Code Assist are disabled."
320
+
export GOOGLE_GENAI_USE_VERTEXAI="false"
321
+
export GOOGLE_GENAI_USE_GCA="false"
322
+
unset GOOGLE_API_KEY
323
+
unset GOOGLE_CLOUD_ACCESS_TOKEN
324
+
fi
325
+
292
326
# Run Gemini CLI with the provided prompt, using JSON output format
293
327
# We capture stdout (JSON) to TEMP_STDOUT and stderr to TEMP_STDERR
0 commit comments