Skip to content

Instantly share code, notes, and snippets.

@Shogun89
Created June 25, 2023 21:54
Show Gist options
  • Save Shogun89/375ffc00a3344b58fbe8950537425130 to your computer and use it in GitHub Desktop.
Save Shogun89/375ffc00a3344b58fbe8950537425130 to your computer and use it in GitHub Desktop.
Fetch GitHub org repo info
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