Skip to content

Commit 41eed13

Browse files
feat: support direct wif
1 parent f7db4b6 commit 41eed13

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

action.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ inputs:
3030
gcp_workload_identity_provider:
3131
description: 'The Google Cloud Workload Identity Provider.'
3232
required: false
33+
gcp_token_format:
34+
description: 'The token format for authentication. Set to "access_token" to generate access tokens (requires service account), or set to empty string for direct WIF. Can be "access_token" or "id_token".'
35+
required: false
36+
default: 'access_token'
37+
gcp_access_token_scopes:
38+
description: 'The access token scopes when using token_format "access_token". Comma-separated list of OAuth 2.0 scopes.'
39+
required: false
40+
default: 'https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile'
3341
gemini_api_key:
3442
description: 'The API key for the Gemini API.'
3543
required: false
@@ -123,8 +131,13 @@ runs:
123131
124132
# Validate Workload Identity Federation inputs
125133
if [[ "${INPUT_GCP_WORKLOAD_IDENTITY_PROVIDER_PRESENT:-false}" == "true" ]]; then
126-
if [[ "${INPUT_GCP_PROJECT_ID_PRESENT:-false}" != "true" || "${INPUT_GCP_SERVICE_ACCOUNT_PRESENT:-false}" != "true" ]]; then
127-
warn "When using Workload Identity Federation ('gcp_workload_identity_provider'), you must also provide 'gcp_project_id' and 'gcp_service_account'."
134+
if [[ "${INPUT_GCP_PROJECT_ID_PRESENT:-false}" != "true" ]]; then
135+
warn "When using Workload Identity Federation ('gcp_workload_identity_provider'), you must also provide 'gcp_project_id'."
136+
fi
137+
# Service account is required when using token_format (default behavior)
138+
# Only optional when explicitly set to empty for direct WIF
139+
if [[ "${INPUT_GCP_TOKEN_FORMAT}" != "" && "${INPUT_GCP_SERVICE_ACCOUNT_PRESENT:-false}" != "true" ]]; then
140+
warn "When using Workload Identity Federation with token generation ('gcp_token_format'), you must also provide 'gcp_service_account'. To use direct WIF without a service account, explicitly set 'gcp_token_format' to an empty string."
128141
fi
129142
if [[ "${INPUT_USE_VERTEX_AI:-false}" == "${INPUT_USE_GEMINI_CODE_ASSIST:-false}" ]]; then
130143
warn "When using Workload Identity Federation, you must set exactly one of 'use_vertex_ai' or 'use_gemini_code_assist' to 'true'."
@@ -153,6 +166,7 @@ runs:
153166
INPUT_GCP_WORKLOAD_IDENTITY_PROVIDER_PRESENT: "${{ inputs.gcp_workload_identity_provider != '' }}"
154167
INPUT_GCP_PROJECT_ID_PRESENT: "${{ inputs.gcp_project_id != '' }}"
155168
INPUT_GCP_SERVICE_ACCOUNT_PRESENT: "${{ inputs.gcp_service_account != '' }}"
169+
INPUT_GCP_TOKEN_FORMAT: '${{ inputs.gcp_token_format }}'
156170
INPUT_USE_VERTEX_AI: '${{ inputs.use_vertex_ai }}'
157171
INPUT_USE_GEMINI_CODE_ASSIST: '${{ inputs.use_gemini_code_assist }}'
158172

@@ -184,8 +198,8 @@ runs:
184198
project_id: '${{ inputs.gcp_project_id }}'
185199
workload_identity_provider: '${{ inputs.gcp_workload_identity_provider }}'
186200
service_account: '${{ inputs.gcp_service_account }}'
187-
token_format: 'access_token'
188-
access_token_scopes: 'https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile'
201+
token_format: '${{ inputs.gcp_token_format }}'
202+
access_token_scopes: '${{ inputs.gcp_access_token_scopes }}'
189203

190204
- name: 'Install Gemini CLI'
191205
id: 'install'

0 commit comments

Comments
 (0)