-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_github.py
More file actions
64 lines (54 loc) · 1.94 KB
/
Copy pathdeploy_github.py
File metadata and controls
64 lines (54 loc) · 1.94 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
#!/usr/bin/env python3
"""
一键部署到 GitHub Pages
需要:git 已安装,GitHub 账号
"""
import subprocess
import os
import webbrowser
# 配置
REPO_NAME = "beijing-metro-pwa"
REPO_DIR = r"C:\Users\Hasee\.qclaw\workspace\metro-pwa"
def run(cmd, cwd=None):
"""运行命令"""
print(f"$ {cmd}")
result = subprocess.run(cmd, shell=True, cwd=cwd, capture_output=True, text=True)
if result.stdout:
print(result.stdout)
if result.returncode != 0:
print(f"Error: {result.stderr}")
return False
return True
def main():
os.chdir(REPO_DIR)
print("=" * 60)
print("北京地铁实时客流监控 - GitHub Pages 部署")
print("=" * 60)
# 1. 初始化 git
print("\n[1/5] 初始化 Git 仓库...")
if not os.path.exists(".git"):
run("git init")
run("git branch -M main")
# 2. 添加文件
print("\n[2/5] 添加文件...")
run("git add .")
run('git commit -m "feat: 北京地铁实时客流监控 PWA"')
# 3. 创建 GitHub 仓库链接
print("\n[3/5] 准备推送...")
print("\n请在 GitHub 上创建仓库后,运行以下命令:")
print(f"\n git remote add origin https://github.com/你的用户名/{REPO_NAME}.git")
print(" git push -u origin main")
# 4. 打开 GitHub 创建仓库页面
print("\n[4/5] 打开 GitHub...")
webbrowser.open("https://github.com/new")
# 5. 提示
print("\n[5/5] 后续步骤:")
print("1. 在打开的页面创建仓库(名称:beijing-metro-pwa)")
print("2. 创建后,在仓库页面复制 HTTPS 地址")
print("3. 在此目录运行以下命令:")
print(f" git remote add origin <你的仓库地址>")
print(" git push -u origin main")
print("4. 进入 Settings → Pages → 选择 main 分支 → Save")
print("5. 等待几分钟,访问:https://你的用户名.github.io/beijing-metro-pwa/")
if __name__ == "__main__":
main()