Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated contributors #70 #83

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions source/contrib/automated_contributors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
from github import Github
from github import Auth

# get access token from environment variable in github actions
access_token = os.environ.get("GITHUB_TOKEN")

if not access_token:
raise ValueError("GITHUB_TOKEN environment variable not set")

auth = Auth.Token(access_token)
g = Github(auth=auth)

repositories = [
"openchemistry/avogadrolibs",
"openchemistry/avogadroapp",
"openchemistry/fragments",
"openchemistry/molecules",
"openchemistry/crystals",
"openchemistry/avogenerators",
"openchemistry/avogadro-commands",
"openchemistry/avogadro-cclib",
]

unique_contributors = set()
contributors_list = []


for repo_name in repositories:
repo = g.get_repo(repo_name)
contributors = repo.get_contributors()

for contributor in contributors:
username = contributor.login

if username not in unique_contributors:
user = g.get_user(username)

# check if the user has a full name and if so, use it else use username
if user is not None and user.name is not None:
contributors_list.append((user.name, username))
else:
contributors_list.append((username, username))
unique_contributors.add(username)

contributors_list.sort()

with open("contributors.md", "w") as contributors_file:
for real_name, username in contributors_list:
contributors_file.write(f"- [{real_name}](https://github.com/{username})\n")

print("Contributors have been updated in contributors.md")
1 change: 1 addition & 0 deletions source/contrib/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@
- yavgech
- yuri@FreeBSD
- Ondřej Čertík
- Kailin Xing
1 change: 1 addition & 0 deletions source/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ pydata-sphinx-theme
sphinx-design
sphinx-copybutton
linkify-it-py
PyGithub