11
2- import githubapp
2+ import githubapps
33from github import Github
44
55# using an access token
66
7+
78def main ():
89
9- with open ('env/private.key' , 'rb' ) as f_private :
10- private_key = f_private .read ()
11- with open ('env/app_id.key' , 'r' ) as f_app_id :
12- app_id = f_app_id .read ()
13- with open ('env/installation_id.key' , 'r' ) as f_installation_id :
14- installation_id = f_installation_id .read ()
15- client_secret = private_key
16- auth = githubapp .Auth (app_id , installation_id , client_secret )
17- access_token = auth .get_access_token ()
18- print (access_token )
19-
20- g = Github (access_token )
21-
22- repo = g .get_repo ("RTa-scp/reserveiframe" )
23- repocontent = []
24- contents = repo .get_contents ("src/reserve" )
25- while contents :
26- file_content = contents .pop (0 )
27- if file_content .type == "dir" :
28- contents .extend (repo .get_contents (file_content .path ))
10+ with open ('env/private.key' , 'rb' ) as f_private :
11+ private_key = f_private .read ()
12+ with open ('env/app_id.key' , 'r' ) as f_app_id :
13+ app_id = f_app_id .read ()
14+ with open ('env/installation_id.key' , 'r' ) as f_installation_id :
15+ installation_id = f_installation_id .read ()
16+ client_secret = private_key
17+ auth = githubapps .Auth (app_id , installation_id , client_secret )
18+ access_token = auth .get_access_token ()
19+
20+ g = Github (access_token )
21+
22+ repo = g .get_repo ("RTa-scp/reserveiframe" )
23+ repocontent = []
24+ contents = repo .get_contents ("src/reserve" , ref = "reserve" )
25+ while contents :
26+ file_content = contents .pop (0 )
27+ if file_content .type == "dir" :
28+ contents .extend (repo .get_contents (file_content .path ))
29+ else :
30+ repocontent .append (file_content .path )
31+ file = "src/reserve/component/theme.md"
32+ if file in repocontent :
33+ contents = repo .get_contents (file , ref = "reserve" )
34+ repo .update_file (contents .path , "update: GithubApps" ,
35+ '---\n url: content\n user: user\n starttime: "2022-04-10"\n endtime: "2022-07-10"\n ---\n <reserve />' , contents .sha , branch = "reserve" )
2936 else :
30- repocontent .append (file_content .path )
31- print (repocontent )
32- file = "src/reserve/component/theme.md"
33- if file in repocontent :
34- contents = repo .get_contents (file , ref = "main" )
35- repo .update_file (contents .path , "update: GithubApps" , '---\n url: content\n user: user\n starttime: "2022-04-10"\n endtime: "2022-07-10"\n ---\n <reserve />' , contents .sha , branch = "main" )
36- else :
37- repo .create_file (file , "create: GithubApps" , '---\n url: content\n user: user\n starttime: "2022-04-10"\n endtime: "2022-07-10"\n ---\n <reserve />' , branch = "main" )
38-
39- # repo.create_file("src/reserve/test.md", "create: GithubApps", '---\nurl: content\nuser: user\nstarttime: "2022-03-10"\nendtime: "2022-06-10"\n---\n<reserve />', branch="main")
40- # contents = repo.get_contents("src/reserve/test.md", ref="main")
41- # repo.update_file(contents.path, "update: GithubApps", '---\nurl: content\nuser: user\nstarttime: "2022-04-10"\nendtime: "2022-07-10"\n---\n<reserve />', contents.sha, branch="main")
37+ repo .create_file (file , "create: GithubApps" ,
38+ '---\n url: content\n user: user\n starttime: "2022-04-11"\n endtime: "2022-07-11"\n ---\n <reserve />' , branch = "reserve" )
39+
4240
4341if __name__ == "__main__" :
44- main ()
42+ main ()
0 commit comments