From 0bf19fa00c82216e8b08613dc4f1b9dc830a00dd Mon Sep 17 00:00:00 2001 From: Yuri Bezgin Date: Wed, 13 Aug 2025 18:26:23 +0100 Subject: [PATCH 1/2] fix: output interruption after first response --- action.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1550f2b46..4af291ee9 100644 --- a/action.yml +++ b/action.yml @@ -147,7 +147,16 @@ runs: fi # Run Gemini CLI with the provided prompt - GEMINI_RESPONSE=$(gemini --yolo --prompt "${PROMPT}") + TEMP_OUTPUT=$(mktemp) + if gemini --yolo --debug --prompt "${PROMPT}" > "${TEMP_OUTPUT}" 2>&1; then + GEMINI_RESPONSE=$(cat "${TEMP_OUTPUT}") + else + echo "Error: Gemini CLI execution failed" + cat "${TEMP_OUTPUT}" + rm -f "${TEMP_OUTPUT}" + exit 1 + fi + rm -f "${TEMP_OUTPUT}" # Set the captured response as a step output, supporting multiline echo "gemini_response<> "${GITHUB_OUTPUT}" From 2591a714bcbe47d9196e04501e128ce3c760e8ea Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Wed, 13 Aug 2025 17:10:51 -0400 Subject: [PATCH 2/2] Clean up output --- action.yml | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/action.yml b/action.yml index 4af291ee9..79562d456 100644 --- a/action.yml +++ b/action.yml @@ -118,7 +118,7 @@ runs: if [[ "${VERSION_INPUT}" == "latest" || "${VERSION_INPUT}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.-]+)?(\+[a-zA-Z0-9\.-]+)?$ ]]; then echo "Installing Gemini CLI from npm: @google/gemini-cli@${VERSION_INPUT}" - npm install -g @google/gemini-cli@"${VERSION_INPUT}" + npm install --silent --no-audit --prefer-offline --global @google/gemini-cli@"${VERSION_INPUT}" else echo "Installing Gemini CLI from GitHub: github:google-gemini/gemini-cli#${VERSION_INPUT}" git clone https://github.com/google-gemini/gemini-cli.git @@ -126,7 +126,7 @@ runs: git checkout "${VERSION_INPUT}" npm install npm run bundle - npm install -g . + npm install --silent --no-audit --prefer-offline --global . fi echo "Verifying installation:" if command -v gemini >/dev/null 2>&1; then @@ -138,32 +138,43 @@ runs: - name: 'Run Gemini CLI' id: 'gemini_run' + shell: 'bash' run: |- - set -e + set -euo pipefail # Unset GEMINI_API_KEY if empty if [ -z "${GEMINI_API_KEY}" ]; then unset GEMINI_API_KEY fi - # Run Gemini CLI with the provided prompt - TEMP_OUTPUT=$(mktemp) - if gemini --yolo --debug --prompt "${PROMPT}" > "${TEMP_OUTPUT}" 2>&1; then - GEMINI_RESPONSE=$(cat "${TEMP_OUTPUT}") - else - echo "Error: Gemini CLI execution failed" - cat "${TEMP_OUTPUT}" + # Create a temporary directory for storing the output, and ensure it's + # cleaned up later + TEMP_OUTPUT="$(mktemp -p "${RUNNER_TEMP}" gemini.XXXXXXXXXX)" + function cleanup { rm -f "${TEMP_OUTPUT}" + } + trap cleanup EXIT + + # Run Gemini CLI with the provided prompt + if ! gemini --yolo --prompt "${PROMPT}" &> "${TEMP_OUTPUT}"; then + GEMINI_RESPONSE="$(cat "${TEMP_OUTPUT}")" + FIRST_LINE="$(echo "${GEMINI_RESPONSE}" | head -n1)" + echo "::error title=Gemini CLI execution failed::${FIRST_LINE}" + echo "${GEMINI_RESPONSE}" exit 1 fi - rm -f "${TEMP_OUTPUT}" + + GEMINI_RESPONSE="$(cat "${TEMP_OUTPUT}")" + + # Print the response + echo "::group::Gemini response" + echo "${GEMINI_RESPONSE}" + echo "::endgroup::" # Set the captured response as a step output, supporting multiline echo "gemini_response<> "${GITHUB_OUTPUT}" echo "${GEMINI_RESPONSE}" >> "${GITHUB_OUTPUT}" echo "EOF" >> "${GITHUB_OUTPUT}" - echo "${GEMINI_RESPONSE}" - shell: 'bash' env: GEMINI_API_KEY: '${{ inputs.gemini_api_key }}' SURFACE: 'GitHub'