@@ -118,15 +118,15 @@ runs:
118118
119119 if [[ "${VERSION_INPUT}" == "latest" || "${VERSION_INPUT}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.-]+)?(\+[a-zA-Z0-9\.-]+)?$ ]]; then
120120 echo "Installing Gemini CLI from npm: @google/gemini-cli@${VERSION_INPUT}"
121- npm install -g @google/gemini-cli@"${VERSION_INPUT}"
121+ npm install --silent --no-audit --prefer-offline --global @google/gemini-cli@"${VERSION_INPUT}"
122122 else
123123 echo "Installing Gemini CLI from GitHub: github:google-gemini/gemini-cli#${VERSION_INPUT}"
124124 git clone https://github.com/google-gemini/gemini-cli.git
125125 cd gemini-cli
126126 git checkout "${VERSION_INPUT}"
127127 npm install
128128 npm run bundle
129- npm install -g .
129+ npm install --silent --no-audit --prefer-offline --global .
130130 fi
131131 echo "Verifying installation:"
132132 if command -v gemini >/dev/null 2>&1; then
@@ -138,23 +138,43 @@ runs:
138138
139139 - name : ' Run Gemini CLI'
140140 id : ' gemini_run'
141+ shell : ' bash'
141142 run : |-
142- set -e
143+ set -euo pipefail
143144
144145 # Unset GEMINI_API_KEY if empty
145146 if [ -z "${GEMINI_API_KEY}" ]; then
146147 unset GEMINI_API_KEY
147148 fi
148149
150+ # Create a temporary directory for storing the output, and ensure it's
151+ # cleaned up later
152+ TEMP_OUTPUT="$(mktemp -p "${RUNNER_TEMP}" gemini.XXXXXXXXXX)"
153+ function cleanup {
154+ rm -f "${TEMP_OUTPUT}"
155+ }
156+ trap cleanup EXIT
157+
149158 # Run Gemini CLI with the provided prompt
150- GEMINI_RESPONSE=$(gemini --yolo --prompt "${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
165+ fi
166+
167+ GEMINI_RESPONSE="$(cat "${TEMP_OUTPUT}")"
168+
169+ # Print the response
170+ echo "::group::Gemini response"
171+ echo "${GEMINI_RESPONSE}"
172+ echo "::endgroup::"
151173
152174 # Set the captured response as a step output, supporting multiline
153175 echo "gemini_response<<EOF" >> "${GITHUB_OUTPUT}"
154176 echo "${GEMINI_RESPONSE}" >> "${GITHUB_OUTPUT}"
155177 echo "EOF" >> "${GITHUB_OUTPUT}"
156- echo "${GEMINI_RESPONSE}"
157- shell : ' bash'
158178 env :
159179 GEMINI_API_KEY : ' ${{ inputs.gemini_api_key }}'
160180 SURFACE : ' GitHub'
0 commit comments