mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 11:59:29 +00:00
feat: wire shared/github-auth.sh into all agent flows (#1216)
* feat: wire shared/github-auth.sh into all agent flows Add offer_github_auth() to shared/common.sh and call it from the inject_env_vars_* functions so all agent flows automatically offer GitHub CLI setup after env var injection — no per-script changes needed. Changes: - shared/common.sh: add offer_github_auth() function, call it from inject_env_vars_ssh() and inject_env_vars_local() - sprite/lib/common.sh: call offer_github_auth() from inject_env_vars_sprite() - OVH is covered automatically (inject_env_vars_ovh delegates to inject_env_vars_ssh) Behavior: - Prompts "Set up GitHub CLI (gh) on this machine? (y/N):" - Defaults to No (non-blocking for users who don't need it) - Skippable via SPAWN_SKIP_GITHUB_AUTH=1 env var for CI/automation - Uses safe_read for curl|bash compatibility - Downloads and runs shared/github-auth.sh on the remote VM Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor: add shared agent setup helpers, deduplicate hetzner scripts (#1236) Add 5 composable helper functions to shared/common.sh (install_agent, verify_agent, get_or_prompt_api_key, inject_env_vars_cb, launch_session) that use the same callback pattern as offer_github_auth and setup_claude_code_config. Refactor all 15 hetzner agent scripts to use them, reducing total line count from 868 to 579 (-33%). Phase 1 of multi-phase rollout — remaining clouds to follow. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
86d77bc059
commit
fffb3591c4
18 changed files with 285 additions and 454 deletions
|
|
@ -12,35 +12,22 @@ fi
|
|||
log_info "OpenCode on Hetzner Cloud"
|
||||
echo ""
|
||||
|
||||
# Provision server
|
||||
ensure_hcloud_token
|
||||
ensure_ssh_key
|
||||
|
||||
SERVER_NAME=$(get_server_name)
|
||||
create_server "${SERVER_NAME}"
|
||||
verify_server_connectivity "${HETZNER_SERVER_IP}"
|
||||
wait_for_cloud_init "${HETZNER_SERVER_IP}" 60
|
||||
|
||||
log_step "Installing OpenCode..."
|
||||
run_server "${HETZNER_SERVER_IP}" "$(opencode_install_cmd)"
|
||||
log_info "OpenCode installed"
|
||||
# Set up callbacks
|
||||
RUN="run_server ${HETZNER_SERVER_IP}"
|
||||
UPLOAD="upload_file ${HETZNER_SERVER_IP}"
|
||||
SESSION="interactive_session ${HETZNER_SERVER_IP}"
|
||||
|
||||
echo ""
|
||||
if [[ -n "${OPENROUTER_API_KEY:-}" ]]; then
|
||||
log_info "Using OpenRouter API key from environment"
|
||||
else
|
||||
OPENROUTER_API_KEY=$(get_openrouter_api_key_oauth 5180)
|
||||
fi
|
||||
|
||||
log_step "Setting up environment variables..."
|
||||
inject_env_vars_ssh "${HETZNER_SERVER_IP}" upload_file run_server \
|
||||
# Install, configure, launch
|
||||
install_agent "OpenCode" "$(opencode_install_cmd)" "$RUN"
|
||||
get_or_prompt_api_key
|
||||
inject_env_vars_cb "$RUN" "$UPLOAD" \
|
||||
"OPENROUTER_API_KEY=${OPENROUTER_API_KEY}"
|
||||
|
||||
echo ""
|
||||
log_info "Hetzner server setup completed successfully!"
|
||||
log_info "Server: ${SERVER_NAME} (ID: ${HETZNER_SERVER_ID}, IP: ${HETZNER_SERVER_IP})"
|
||||
echo ""
|
||||
|
||||
log_step "Starting OpenCode..."
|
||||
sleep 1
|
||||
clear
|
||||
interactive_session "${HETZNER_SERVER_IP}" "source ~/.zshrc && opencode"
|
||||
launch_session "Hetzner server" "$SESSION" "source ~/.zshrc && opencode"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue