Skip to content

Commit

Permalink
package update
Browse files Browse the repository at this point in the history
  • Loading branch information
James Wood authored and James Wood committed Nov 9, 2024
1 parent 04f9a59 commit f9474e7
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions hitide_repos/hitide_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,19 @@ def get_latest_release(repo_name):

def get_package_versions(repo_name, token):
owner, package_name = repo_name.split("/")
# GitHub API URL for the container package versions
versions_url = f"https://api.github.com/orgs/{owner}/packages/container/{package_name}/versions"

# Headers for authentication
headers = {
"Authorization": f"Bearer {token}",
"Accept": "application/vnd.github.v3+json"
}

# Fetch package versions
response_versions = requests.get(versions_url, headers=headers)
if response_versions.status_code != 200:
print(f"Failed to retrieve package versions: {response_versions.status_code}")
response = requests.get(versions_url, headers=headers)
if response.status_code != 200:
print(f"Failed to retrieve package versions: {response.status_code}")
return None

# Parse and filter versions by labels "ops" or "uat"
versions = response_versions.json()
versions_with_labels = [
version for version in versions
if 'tags' in version['metadata']['container'] and
any(label in version['metadata']['container']['tags'] for label in ["ops", "uat"])
]

return versions_with_labels
return response.json()


def get_repos():
Expand Down Expand Up @@ -165,7 +154,7 @@ def main():

versions = get_package_versions(repo_name, github_token)
if versions:
print("Versions with 'ops' or 'uat' Labels:")
print("Package Versions:")
for version in versions:
print(f"Version ID: {version['id']}, Tags: {version['metadata']['container']['tags']}")

Expand Down

0 comments on commit f9474e7

Please sign in to comment.