@@ -60,6 +60,9 @@ outputs:
6060 summary :
6161 description : ' The summarized output from the Gemini CLI execution.'
6262 value : ' ${{ steps.gemini_run.outputs.gemini_response }}'
63+ error :
64+ description : ' The error output from the Gemini CLI execution, if any.'
65+ value : ' ${{ steps.gemini_run.outputs.gemini_errors }}'
6366
6467runs :
6568 using : ' composite'
@@ -149,22 +152,20 @@ runs:
149152
150153 # Create a temporary directory for storing the output, and ensure it's
151154 # cleaned up later
152- TEMP_OUTPUT="$(mktemp -p "${RUNNER_TEMP}" gemini.XXXXXXXXXX)"
155+ TEMP_STDOUT="$(mktemp -p "${RUNNER_TEMP}" gemini-out.XXXXXXXXXX)"
156+ TEMP_STDERR="$(mktemp -p "${RUNNER_TEMP}" gemini-err.XXXXXXXXXX)"
153157 function cleanup {
154- rm -f "${TEMP_OUTPUT }"
158+ rm -f "${TEMP_STDOUT}" "${TEMP_STDERR }"
155159 }
156160 trap cleanup EXIT
157161
158162 # Run Gemini CLI with the provided prompt
159- if ! gemini --yolo --prompt "${PROMPT}" &> "${TEMP_OUTPUT}"; then
160- GEMINI_RESPONSE="$(cat "${TEMP_OUTPUT}")"
161- FIRST_LINE="$(echo "${GEMINI_RESPONSE}" | head -n1)"
162- echo "::error title=Gemini CLI execution failed::${FIRST_LINE}"
163- echo "${GEMINI_RESPONSE}"
164- exit 1
163+ FAILED=false
164+ if ! gemini --yolo --prompt "${PROMPT}" 2> "${TEMP_STDERR}" 1> "${TEMP_STDOUT}"; then
165+ FAILED=true
165166 fi
166167
167- GEMINI_RESPONSE="$(cat "${TEMP_OUTPUT }")"
168+ GEMINI_RESPONSE="$(cat "${TEMP_STDOUT }")"
168169
169170 # Print the response
170171 echo "::group::Gemini response"
@@ -175,6 +176,25 @@ runs:
175176 echo "gemini_response<<EOF" >> "${GITHUB_OUTPUT}"
176177 echo "${GEMINI_RESPONSE}" >> "${GITHUB_OUTPUT}"
177178 echo "EOF" >> "${GITHUB_OUTPUT}"
179+
180+ GEMINI_ERRORS="$(cat "${TEMP_STDERR}")"
181+
182+ # Print any errors
183+ echo "::group::Gemini error messages"
184+ echo "${GEMINI_ERRORS}"
185+ echo "::endgroup::"
186+
187+ # Set the captured errors as a step output, supporting multiline
188+ echo "gemini_errors<<EOF" >> "${GITHUB_OUTPUT}"
189+ echo "${GEMINI_ERRORS}" >> "${GITHUB_OUTPUT}"
190+ echo "EOF" >> "${GITHUB_OUTPUT}"
191+
192+ if [[ "${FAILED}" = true ]]; then
193+ LAST_LINE="$(echo "${GEMINI_ERRORS}" | tail -n1)"
194+ echo "::error title=Gemini CLI execution failed::${LAST_LINE}"
195+ echo "See logs for more details"
196+ exit 1
197+ fi
178198 env :
179199 GEMINI_API_KEY : ' ${{ inputs.gemini_api_key }}'
180200 SURFACE : ' GitHub'
0 commit comments