Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DEVOPS-95 added pagination for repo end point #2

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

Merged
merged 1 commit into from
Jun 26, 2024
Merged
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
29 changes: 25 additions & 4 deletions create_new_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,35 @@ def list_repos_in_org(org_name: str):
"Authorization": f"Bearer {os.getenv('GH_TOKEN')}",
"X-GitHub-Api-Version": "2022-11-28"
}
params = {
'sort': 'created',
'per_page': 30,
'page': 1
}

# List to hold all repositories
all_repositories = []
# Paginate through all pages
while True:
# Make the GET request with query parameters
response = requests.get(url=repo_url, headers=headers, params=params)

# Check the response status code
if response.status_code == 200:
# Parse the JSON response
repositories = response.json()
if not repositories:
break
all_repositories.extend(repositories)
params["page"] += 1
else:
print(f"Failed to fetch repositories: {response.status_code}")
break

response = requests.get(url=repo_url, headers=headers)
response_json = response.json()
# print(response_json)

repo_names = []

for repo in response_json:
for repo in all_repositories:
print(repo['name'])
repo_names.append(repo['name'])

Expand Down