File size: 4,005 Bytes
06464c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/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..."