@@ -80,9 +80,66 @@ outputs:
8080runs :
8181 using : ' composite'
8282 steps :
83- - name : ' Validate inputs'
83+ - name : ' Validate Inputs'
84+ id : ' validate_inputs'
8485 shell : ' bash'
85- run : ' ${{ github.action_path }}/scripts/validate-inputs.sh'
86+ run : |-
87+ set -euo pipefail
88+
89+ # Emit a clear warning in three places without failing the step
90+ warn() {
91+ local msg="$1"
92+ echo "WARNING: ${msg}" >&2
93+ echo "::warning title=Input validation::${msg}"
94+ if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
95+ {
96+ echo "### Input validation warnings"
97+ echo
98+ echo "- ${msg}"
99+ } >> "${GITHUB_STEP_SUMMARY}"
100+ fi
101+ }
102+
103+ # Validate the count of authentication methods
104+ auth_methods=0
105+ if [[ "${INPUT_GEMINI_API_KEY_PRESENT:-false}" == "true" ]]; then ((auth_methods++)); fi
106+ if [[ "${INPUT_GOOGLE_API_KEY_PRESENT:-false}" == "true" ]]; then ((auth_methods++)); fi
107+ if [[ "${INPUT_GCP_WORKLOAD_IDENTITY_PROVIDER_PRESENT:-false}" == "true" ]]; then ((auth_methods++)); fi
108+
109+ if [[ ${auth_methods} -eq 0 ]]; then
110+ warn "No authentication method provided. Please provide one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
111+ fi
112+
113+ if [[ ${auth_methods} -gt 1 ]]; then
114+ warn "Multiple authentication methods provided. Please use only one of 'gemini_api_key', 'google_api_key', or 'gcp_workload_identity_provider'."
115+ fi
116+
117+ # Validate Workload Identity Federation inputs
118+ if [[ "${INPUT_GCP_WORKLOAD_IDENTITY_PROVIDER_PRESENT:-false}" == "true" ]]; then
119+ if [[ "${INPUT_GCP_PROJECT_ID_PRESENT:-false}" != "true" || "${INPUT_GCP_SERVICE_ACCOUNT_PRESENT:-false}" != "true" ]]; then
120+ warn "When using Workload Identity Federation ('gcp_workload_identity_provider'), you must also provide 'gcp_project_id' and 'gcp_service_account'."
121+ fi
122+ if [[ "${INPUT_USE_VERTEX_AI:-false}" == "${INPUT_USE_GEMINI_CODE_ASSIST:-false}" ]]; then
123+ warn "When using Workload Identity Federation, you must set exactly one of 'use_vertex_ai' or 'use_gemini_code_assist' to 'true'."
124+ fi
125+ fi
126+
127+ # Validate Vertex AI API Key
128+ if [[ "${INPUT_GOOGLE_API_KEY_PRESENT:-false}" == "true" ]]; then
129+ if [[ "${INPUT_USE_VERTEX_AI:-false}" != "true" ]]; then
130+ warn "When using 'google_api_key', you must set 'use_vertex_ai' to 'true'."
131+ fi
132+ if [[ "${INPUT_USE_GEMINI_CODE_ASSIST:-false}" == "true" ]]; then
133+ warn "When using 'google_api_key', 'use_gemini_code_assist' cannot be 'true'."
134+ fi
135+ fi
136+
137+ # Validate Gemini API Key
138+ if [[ "${INPUT_GEMINI_API_KEY_PRESENT:-false}" == "true" ]]; then
139+ if [[ "${INPUT_USE_VERTEX_AI:-false}" == "true" || "${INPUT_USE_GEMINI_CODE_ASSIST:-false}" == "true" ]]; then
140+ warn "When using 'gemini_api_key', both 'use_vertex_ai' and 'use_gemini_code_assist' must be 'false'."
141+ fi
142+ fi
86143 env :
87144 INPUT_GEMINI_API_KEY_PRESENT : " ${{ inputs.gemini_api_key != '' }}"
88145 INPUT_GOOGLE_API_KEY_PRESENT : " ${{ inputs.google_api_key != '' }}"
0 commit comments