#!/bin/bash # Trade Copilot — one-shot GitHub deploy # Double-click this file to run it. cd "$(dirname "$0")" echo "============================================" echo " Trade Copilot — GitHub Deploy" echo "============================================" echo echo "This will:" echo " 1. Ask for your GitHub token (paste it, it won't show)" echo " 2. Create the 'trade-copilot' repo on your GitHub" echo " 3. Push all files" echo # ── Get token ────────────────────────────────────────────────────────────── echo "Go to: https://github.com/settings/tokens/new" echo " • Note: trade-copilot" echo " • Expiration: 90 days" echo " • Scope: check 'repo' (full control)" echo " • Click 'Generate token' and copy it" echo read -s -p "Paste your GitHub token here (input hidden): " TOKEN echo if [ -z "$TOKEN" ]; then echo "No token entered. Exiting." read -p "Press Enter to close..."; exit 1 fi # ── Get username from token ──────────────────────────────────────────────── echo "Verifying token..." USERNAME=$(curl -s -H "Authorization: token $TOKEN" https://api.github.com/user | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('login',''))" 2>/dev/null) if [ -z "$USERNAME" ]; then echo "Token invalid or GitHub unreachable. Check your token and try again." read -p "Press Enter to close..."; exit 1 fi echo "Logged in as: $USERNAME" # ── Create repo (ignore error if already exists) ─────────────────────────── echo "Creating GitHub repo 'trade-copilot'..." RESP=$(curl -s -o /dev/null -w "%{http_code}" \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"trade-copilot","private":true,"description":"AI trading copilot dashboard"}' \ https://api.github.com/user/repos) if [ "$RESP" = "201" ]; then echo "Repo created." elif [ "$RESP" = "422" ]; then echo "Repo already exists — will push to it." else echo "Unexpected response $RESP creating repo. Trying to push anyway..." fi # ── Git setup and push ───────────────────────────────────────────────────── echo "Setting up git..." git init -q git add -A git diff --cached --quiet && echo "Nothing new to commit." || git commit -q -m "trade copilot v1" REMOTE_URL="https://${USERNAME}:${TOKEN}@github.com/${USERNAME}/trade-copilot.git" git remote remove origin 2>/dev/null || true git remote add origin "$REMOTE_URL" # Rename branch to main if needed git branch -M main 2>/dev/null || true echo "Pushing to GitHub..." if git push -u origin main --force 2>&1; then echo echo "============================================" echo " SUCCESS! Code is on GitHub." echo "============================================" echo echo "Now deploy on Render (free, EU region):" echo " 1. Go to https://render.com and sign up with GitHub" echo " 2. Click 'New +' → 'Web Service'" echo " 3. Click 'GitHub' button → authorize Render" echo " 4. Select repo: ${USERNAME}/trade-copilot" echo " 5. Render auto-reads render.yaml → click 'Create Web Service'" echo " 6. Wait ~3 min → your URL appears at the top" echo echo "Your repo: https://github.com/${USERNAME}/trade-copilot" echo else echo echo "Push failed. Common fix: make sure the repo exists at" echo "https://github.com/new — create it manually named 'trade-copilot'" echo "then run this script again." fi # Clean token from git config immediately for security git remote remove origin 2>/dev/null || true git remote add origin "https://github.com/${USERNAME}/trade-copilot.git" echo "Token removed from git config." echo read -p "Press Enter to close this window..."