@@ -118,15 +118,15 @@ runs:
118
118
119
119
if [[ "${VERSION_INPUT}" == "latest" || "${VERSION_INPUT}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.-]+)?(\+[a-zA-Z0-9\.-]+)?$ ]]; then
120
120
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}"
122
122
else
123
123
echo "Installing Gemini CLI from GitHub: github:google-gemini/gemini-cli#${VERSION_INPUT}"
124
124
git clone https://github.com/google-gemini/gemini-cli.git
125
125
cd gemini-cli
126
126
git checkout "${VERSION_INPUT}"
127
127
npm install
128
128
npm run bundle
129
- npm install -g .
129
+ npm install --silent --no-audit --prefer-offline --global .
130
130
fi
131
131
echo "Verifying installation:"
132
132
if command -v gemini >/dev/null 2>&1; then
@@ -138,23 +138,43 @@ runs:
138
138
139
139
- name : ' Run Gemini CLI'
140
140
id : ' gemini_run'
141
+ shell : ' bash'
141
142
run : |-
142
- set -e
143
+ set -euo pipefail
143
144
144
145
# Unset GEMINI_API_KEY if empty
145
146
if [ -z "${GEMINI_API_KEY}" ]; then
146
147
unset GEMINI_API_KEY
147
148
fi
148
149
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
+
149
158
# 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::"
151
173
152
174
# Set the captured response as a step output, supporting multiline
153
175
echo "gemini_response<<EOF" >> "${GITHUB_OUTPUT}"
154
176
echo "${GEMINI_RESPONSE}" >> "${GITHUB_OUTPUT}"
155
177
echo "EOF" >> "${GITHUB_OUTPUT}"
156
- echo "${GEMINI_RESPONSE}"
157
- shell : ' bash'
158
178
env :
159
179
GEMINI_API_KEY : ' ${{ inputs.gemini_api_key }}'
160
180
SURFACE : ' GitHub'
0 commit comments