-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_deploy.py
More file actions
85 lines (73 loc) · 3.04 KB
/
Copy pathquick_deploy.py
File metadata and controls
85 lines (73 loc) · 3.04 KB
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
"""
Quick GitHub + Render Deployment Script
"""
import subprocess
import sys
from pathlib import Path
def run_command(cmd, description):
"""Run shell command and return success status"""
print(f'\n{description}...')
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, cwd=Path(__file__).parent)
if result.returncode == 0:
print(f'✓ Success')
if result.stdout:
print(result.stdout[:500])
return True
else:
print(f'✗ Error: {result.stderr[:500]}')
return False
except Exception as e:
print(f'✗ Exception: {str(e)}')
return False
def main():
print('🚀 GitHub + Render Deployment\n')
# Check if git is initialized
git_dir = Path(__file__).parent / '.git'
if not git_dir.exists():
print('📦 Step 1: Initialize Git Repository')
run_command('git init', 'Initializing git')
run_command('git add .', 'Adding all files')
run_command('git commit -m "Initial commit - Telegram bot with 21 scanners"', 'Creating commit')
else:
print('✓ Git already initialized')
print('\n📋 Step 2: GitHub Repository Setup')
print('Choose an option:')
print('1. Create new GitHub repo manually')
print('2. I already have a GitHub repo')
choice = input('\nEnter choice (1 or 2): ').strip()
if choice == '1':
print('\n📝 Create GitHub Repository:')
print('1. Go to: https://github.com/new')
print('2. Repository name: telegram-bot')
print('3. Set to Public or Private')
print('4. DO NOT initialize with README')
print('5. Click "Create repository"')
print('\nAfter creating, enter your repo URL...')
repo_url = input('Enter GitHub repo URL (e.g., https://github.com/username/telegram-bot.git): ').strip()
if not repo_url:
print('✗ No URL provided. Exiting.')
return
print(f'\n📤 Step 3: Pushing to GitHub')
run_command('git branch -M main', 'Setting main branch')
run_command(f'git remote add origin {repo_url}', 'Adding remote')
run_command('git push -u origin main', 'Pushing to GitHub')
print('\n✅ Code pushed to GitHub!')
print('\n🎨 Step 4: Deploy on Render')
print('1. Go to: https://dashboard.render.com/create?type=web')
print('2. Click "Connect account" if not connected')
print('3. Select your repository: telegram-bot')
print('4. Configure:')
print(' - Name: API_bot')
print(' - Runtime: Python 3')
print(' - Build Command: pip install -r requirements.txt')
print(' - Start Command: python bot.py')
print(' - Plan: Free')
print('5. Click "Advanced" → Add Environment Variable:')
print(' - Key: TELEGRAM_BOT_TOKEN')
print(' - Value: (paste your bot token)')
print('6. Click "Create Web Service"')
print('\n🚀 Your bot will be live in ~2 minutes!')
print('📊 Monitor logs: https://dashboard.render.com')
if __name__ == '__main__':
main()