mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
fix: use cross-platform timeout for Claude Code installation (#700)
The GNU `timeout` command is not available on macOS. Check if it exists and use it when available, otherwise run without timeout. Also extracts the version into a CLAUDE_CODE_VERSION variable for easier maintenance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
13
action.yml
13
action.yml
@@ -191,20 +191,23 @@ runs:
|
|||||||
|
|
||||||
# Install Claude Code if no custom executable is provided
|
# Install Claude Code if no custom executable is provided
|
||||||
if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then
|
if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then
|
||||||
echo "Installing Claude Code..."
|
CLAUDE_CODE_VERSION="2.0.50"
|
||||||
|
echo "Installing Claude Code v${CLAUDE_CODE_VERSION}..."
|
||||||
for attempt in 1 2 3; do
|
for attempt in 1 2 3; do
|
||||||
echo "Installation attempt $attempt..."
|
echo "Installation attempt $attempt..."
|
||||||
if timeout 120 bash -c 'curl -fsSL https://claude.ai/install.sh | bash -s -- 2.0.50'; then
|
if command -v timeout &> /dev/null; then
|
||||||
echo "Claude Code installed successfully"
|
timeout 120 bash -c "curl -fsSL https://claude.ai/install.sh | bash -s -- $CLAUDE_CODE_VERSION" && break
|
||||||
break
|
else
|
||||||
|
curl -fsSL https://claude.ai/install.sh | bash -s -- "$CLAUDE_CODE_VERSION" && break
|
||||||
fi
|
fi
|
||||||
if [ $attempt -eq 3 ]; then
|
if [ $attempt -eq 3 ]; then
|
||||||
echo "Failed to install Claude Code after 3 attempts"
|
echo "Failed to install Claude Code after 3 attempts"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Installation timed out or failed, retrying..."
|
echo "Installation failed, retrying..."
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
echo "Claude Code installed successfully"
|
||||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||||
else
|
else
|
||||||
echo "Using custom Claude Code executable: ${{ inputs.path_to_claude_code_executable }}"
|
echo "Using custom Claude Code executable: ${{ inputs.path_to_claude_code_executable }}"
|
||||||
|
|||||||
@@ -117,20 +117,23 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then
|
if [ -z "${{ inputs.path_to_claude_code_executable }}" ]; then
|
||||||
echo "Installing Claude Code..."
|
CLAUDE_CODE_VERSION="2.0.50"
|
||||||
|
echo "Installing Claude Code v${CLAUDE_CODE_VERSION}..."
|
||||||
for attempt in 1 2 3; do
|
for attempt in 1 2 3; do
|
||||||
echo "Installation attempt $attempt..."
|
echo "Installation attempt $attempt..."
|
||||||
if timeout 120 bash -c 'curl -fsSL https://claude.ai/install.sh | bash -s -- 2.0.50'; then
|
if command -v timeout &> /dev/null; then
|
||||||
echo "Claude Code installed successfully"
|
timeout 120 bash -c "curl -fsSL https://claude.ai/install.sh | bash -s -- $CLAUDE_CODE_VERSION" && break
|
||||||
break
|
else
|
||||||
|
curl -fsSL https://claude.ai/install.sh | bash -s -- "$CLAUDE_CODE_VERSION" && break
|
||||||
fi
|
fi
|
||||||
if [ $attempt -eq 3 ]; then
|
if [ $attempt -eq 3 ]; then
|
||||||
echo "Failed to install Claude Code after 3 attempts"
|
echo "Failed to install Claude Code after 3 attempts"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Installation timed out or failed, retrying..."
|
echo "Installation failed, retrying..."
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
echo "Claude Code installed successfully"
|
||||||
else
|
else
|
||||||
echo "Using custom Claude Code executable: ${{ inputs.path_to_claude_code_executable }}"
|
echo "Using custom Claude Code executable: ${{ inputs.path_to_claude_code_executable }}"
|
||||||
# Add the directory containing the custom executable to PATH
|
# Add the directory containing the custom executable to PATH
|
||||||
|
|||||||
Reference in New Issue
Block a user