Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ 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
cd gemini-cli
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
Expand All @@ -138,23 +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

# 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
GEMINI_RESPONSE=$(gemini --yolo --prompt "${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

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<<EOF" >> "${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'
Expand Down
Loading