@@ -231,6 +231,10 @@ runs:
231231 GEMINI_CLI_VERSION : ' ${{ inputs.gemini_cli_version }}'
232232 EXTENSIONS : ' ${{ inputs.extensions }}'
233233 USE_PNPM : ' ${{ inputs.use_pnpm }}'
234+ GOOGLE_CLOUD_ACCESS_TOKEN : ' ${{ steps.auth.outputs.access_token }}'
235+ GOOGLE_GENAI_USE_VERTEXAI : ' ${{ inputs.use_vertex_ai }}'
236+ GEMINI_API_KEY : ' ${{ inputs.gemini_api_key }}'
237+ GOOGLE_API_KEY : ' ${{ inputs.google_api_key }}'
234238 shell : ' bash'
235239 run : |-
236240 set -exuo pipefail
@@ -265,11 +269,14 @@ runs:
265269
266270 # Sanitize authentication environment variables to avoid conflicts when installing extensions.
267271 if [[ -n "${GOOGLE_CLOUD_ACCESS_TOKEN:-}" ]]; then
272+ echo "Using Workload Identity Federation; unsetting conflicting API keys."
268273 unset GEMINI_API_KEY
269274 unset GOOGLE_API_KEY
270275 elif [[ "${GOOGLE_GENAI_USE_VERTEXAI:-false}" == "true" && -n "${GOOGLE_API_KEY:-}" ]]; then
276+ echo "Using Vertex AI API Key; unsetting conflicting Gemini API key."
271277 unset GEMINI_API_KEY
272278 elif [[ -n "${GEMINI_API_KEY:-}" ]]; then
279+ echo "Using Gemini API Key; ensuring Vertex AI and Code Assist are disabled."
273280 export GOOGLE_GENAI_USE_VERTEXAI="false"
274281 export GOOGLE_GENAI_USE_GCA="false"
275282 unset GOOGLE_API_KEY
@@ -295,7 +302,7 @@ runs:
295302 echo "Starting Gemini CLI execution..."
296303
297304 echo "--- Environment variables ---"
298- env | sort | grep -vE "TOKEN|KEY|PASS|SECRET" || true
305+ env | sort | grep -vE "TOKEN|KEY|PASS|SECRET|GHA_CREDS " || true
299306 echo "--- End environment variables ---"
300307
301308 # Create a temporary directory for storing the output, and ensure it's
@@ -316,9 +323,13 @@ runs:
316323 # 2. Vertex AI API Key (use_vertex_ai with google_api_key)
317324 # 3. Gemini API Key (gemini_api_key)
318325 if [[ -n "${GOOGLE_CLOUD_ACCESS_TOKEN:-}" ]]; then
319- echo "Using Workload Identity Federation; unsetting conflicting API keys ."
326+ echo "Using Workload Identity Federation; unsetting conflicting credentials ."
320327 unset GEMINI_API_KEY
321328 unset GOOGLE_API_KEY
329+ # Aggressively unset credential file pointers to prevent CLI from picking them up
330+ unset GOOGLE_APPLICATION_CREDENTIALS
331+ unset CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE
332+ unset GOOGLE_GHA_CREDS_PATH
322333 elif [[ "${GOOGLE_GENAI_USE_VERTEXAI:-false}" == "true" && -n "${GOOGLE_API_KEY:-}" ]]; then
323334 echo "Using Vertex AI API Key; unsetting conflicting Gemini API key."
324335 unset GEMINI_API_KEY
0 commit comments