soiz1 commited on
Commit
d76619e
·
verified ·
1 Parent(s): 373750e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import shutil
4
+
5
+ # GitHubのリポジトリURL
6
+ repo_url = "https://github.com/izum00/penguinmod-s4s"
7
+
8
+ # 環境変数からトークンを取得
9
+ token = os.getenv("github_token")
10
+ if not token:
11
+ raise RuntimeError("環境変数 'github_token' が設定されていません。")
12
+
13
+ # 認証情報付きのURLを作成
14
+ authed_url = repo_url.replace("https://", f"https://{token}@")
15
+
16
+ # カレントディレクトリのパス
17
+ current_dir = os.getcwd()
18
+
19
+ # .gitディレクトリがなければ初期化
20
+ if not os.path.exists(os.path.join(current_dir, ".git")):
21
+ subprocess.run(["git", "init"], check=True)
22
+ subprocess.run(["git", "remote", "add", "origin", authed_url], check=True)
23
+ else:
24
+ subprocess.run(["git", "remote", "set-url", "origin", authed_url], check=True)
25
+
26
+ # Gitの操作
27
+ subprocess.run(["git", "add", "."], check=True)
28
+ subprocess.run(["git", "commit", "-m", "auto commit from script"], check=True)
29
+ subprocess.run(["git", "branch", "-M", "main"], check=True)
30
+ subprocess.run(["git", "push", "-u", "origin", "main", "--force"], check=True)