Created
June 25, 2023 21:54
-
-
Save Shogun89/375ffc00a3344b58fbe8950537425130 to your computer and use it in GitHub Desktop.
Fetch GitHub org repo info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import github as Github | |
def get_repo_information(org_name, access_token): | |
git = Github(access_token) | |
org = git.get_organization(org_name) | |
repositories = org.get_repos() | |
data = [] | |
for repo in repositories: | |
try: | |
last_commit = repo.get_commits().get_page(0)[0] | |
data.append( | |
{ | |
"Repository": repo.name, | |
"Creation Date": repo.created_at, | |
"Last Commit Date": last_commit.commit.author.date, | |
} | |
) | |
except Exception as e: | |
data.append( | |
{ | |
"Repository": repo.name, | |
"Creation Date": repo.created_at, | |
"Last Commit Date": 0, | |
} | |
) | |
df = pd.DataFrame(data) | |
return df | |
organization_name = "<your_org>" | |
personal_access_token = "<your_auth_token>" | |
repo_info = get_repo_information(organization_name, personal_access_token) | |
repo_info.to_csv("repository_info.csv", index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment