Created
September 27, 2022 15:37
-
-
Save b-per/8314988304af8cf4a700908e40bb4aed to your computer and use it in GitHub Desktop.
Retrieve dependencies for all releases of dbt packages
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
# this script requires a github personal access token (PAT) with read repos scope | |
import requests | |
import os | |
s = requests.Session() | |
GITHUB_API_PAT = os.environ['GITHUB_API_PAT'] | |
def get_releases(repo): | |
headers = { | |
'Accept': 'application/vnd.github+json', | |
'Authorization': f'Bearer {GITHUB_API_PAT}', | |
} | |
response = s.get(f'https://api.github.com/repos/{repo}/releases', headers=headers) | |
return [release['tag_name'] for release in response.json()] | |
def get_dependencies(repo, release): | |
response = s.get(f'https://raw.githubusercontent.com/{repo}/{release}/packages.yml') | |
print(response.text) | |
def print_dependencies(repo): | |
print(f'### {repo} ###\n') | |
releases = get_releases(repo) | |
print(f'Releases: {releases}\n') | |
for release in releases: | |
print(f'{repo} - {release}') | |
get_dependencies(repo, release) | |
print('') | |
print(f'--------------------------------\n') | |
# for repo in ['snowplow/dbt-snowplow-utils','dbt-labs/dbt-codegen']: | |
for repo in ['brooklyn-data/dbt_artifacts','dbt-labs/dbt-codegen']: | |
print_dependencies(repo) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment