-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_readme.py
More file actions
23 lines (17 loc) · 786 Bytes
/
update_readme.py
File metadata and controls
23 lines (17 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests
import os
token = os.environ["GITHUB_TOKEN"]
username = "pyguy-programming"
headers = {"Authorization": f"token {token}"}
repos = requests.get(f"https://api.github.com/users/{username}/repos?sort=updated&per_page=100", headers=headers).json()
repo_list = "\n".join([
f'<a href="{r["html_url"]}"><img src="https://github-readme-stats.vercel.app/api/pin/?username={username}&repo={r["name"]}&theme=react" alt="{r["name"]}"></a>'
for r in repos if not r['fork']
])
with open("README.md", "r") as f:
readme = f.read()
new_readme = readme.split("<!-- REPOS_START -->")[0]
new_readme += "<!-- REPOS_START -->\n" + repo_list + "\n<!-- REPOS_END -->"
new_readme += readme.split("<!-- REPOS_END -->")[1]
with open("README.md", "w") as f:
f.write(new_readme)