File size: 945 Bytes
4b78a73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
cd "$(dirname "$0")"

echo "Pushing updated files to GitHub..."
echo
read -s -p "Paste your GitHub token: " TOKEN
echo

USERNAME=$(curl -s -H "Authorization: token $TOKEN" https://api.github.com/user | python3 -c "import sys,json; print(json.load(sys.stdin).get('login',''))" 2>/dev/null)
if [ -z "$USERNAME" ]; then
  echo "Token invalid. Try again."
  read -p "Press Enter to close..."; exit 1
fi
echo "Logged in as: $USERNAME"

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"
git add -A
git commit -m "Add Dockerfile and HF Spaces config" 2>/dev/null || echo "Nothing new to commit"
git push -u origin main --force

git remote remove origin 2>/dev/null || true
git remote add origin "https://github.com/${USERNAME}/trade-copilot.git"

echo
echo "Done! GitHub is up to date."
echo
read -p "Press Enter to close..."