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
Adds a validation step to the action to ensure that authentication inputs are configured correctly. This prevents common misconfigurations and improves security.
The validation is performed by a new script, `scripts/validate-inputs.sh`, which is called as the first step in the action.
Key changes:
- A new `validate-inputs.sh` script is added to check authentication configuration.
- The `action.yml` is updated to call this script.
- Follows principle of least privilege by using boolean flags to indicate whether inputs are set.
- The validation enforces that exactly one authentication method is used, providing clear error messages to the user if the configuration is invalid. This makes the action more robust, secure, and easier to debug.
if [[ "${gemini_api_key_present}"=='true' ]];then((auth_methods++));fi
18
+
if [[ "${google_api_key_present}"=='true' ]];then((auth_methods++));fi
19
+
if [[ "${gcp_workload_identity_provider_present}"=='true' ]];then((auth_methods++));fi
20
+
21
+
if [[ ${auth_methods}-eq 0 ]];then
22
+
echo"::error title=Configuration error::No authentication method provided. Please provide one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
23
+
exit 1
24
+
fi
25
+
26
+
if [[ ${auth_methods}-gt 1 ]];then
27
+
echo"::error title=Configuration error::Multiple authentication methods provided. Please use only one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
28
+
exit 1
29
+
fi
30
+
31
+
# WIF validation
32
+
if [[ "${gcp_workload_identity_provider_present}"=='true' ]];then
33
+
if [[ "${gcp_project_id_present}"!='true'||"${gcp_service_account_present}"!='true' ]];then
34
+
echo"::error title=Configuration error::When using Workload Identity Federation ('gcp_workload_identity_provider'), you must also provide 'gcp_project_id' and 'gcp_service_account'."
35
+
exit 1
36
+
fi
37
+
if [[ "${use_vertex_ai}"!='true'&&"${use_gemini_code_assist}"!='true' ]];then
38
+
echo"::error title=Configuration error::When using Workload Identity Federation, you must set either 'use_vertex_ai' or 'use_gemini_code_assist' to 'true'."
39
+
exit 1
40
+
fi
41
+
if [[ "${use_vertex_ai}"=='true'&&"${use_gemini_code_assist}"=='true' ]];then
42
+
echo"::error title=Configuration error::'use_vertex_ai' and 'use_gemini_code_assist' cannot both be 'true'."
43
+
exit 1
44
+
fi
45
+
fi
46
+
47
+
# Vertex AI API Key validation
48
+
if [[ "${google_api_key_present}"=='true' ]];then
49
+
if [[ "${use_vertex_ai}"!='true' ]];then
50
+
echo"::error title=Configuration error::When using 'google_api_key', you must set 'use_vertex_ai' to 'true'."
51
+
exit 1
52
+
fi
53
+
if [[ "${use_gemini_code_assist}"=='true' ]];then
54
+
echo"::error title=Configuration error::'use_gemini_code_assist' cannot be 'true' when using 'google_api_key'."
55
+
exit 1
56
+
fi
57
+
fi
58
+
59
+
# Gemini API Key validation
60
+
if [[ "${gemini_api_key_present}"=='true' ]];then
61
+
if [[ "${use_vertex_ai}"=='true'||"${use_gemini_code_assist}"=='true' ]];then
62
+
echo"::error title=Configuration error::When using 'gemini_api_key', both 'use_vertex_ai' and 'use_gemini_code_assist' must be 'false'."
0 commit comments