Skip to content

Instantly share code, notes, and snippets.

View henchc's full-sized avatar

Christopher Hench henchc

View GitHub Profile
pr = {
'title': '{}: {}...{}'.format(repo,
commit_info[repo]['live'],
commit_info[repo]['latest']),
'body': body,
'base': 'master',
'head': 'henchbot:{}_bump'.format(repo)
}
res = requests.post('https://api.github.com/repos/jupyterhub/mybinder.org-deploy/pulls',
headers={'Authorization': 'token {}'.format(TOKEN)}, json=pr)
if repo == 'repo2docker':
compare_url = 'https://github.com/jupyter/repo2docker/compare/{}...{}'.format(
commit_info['repo2docker']['live'],
commit_info['repo2docker']['latest'])
body = '\n'.join(['This is a repo2docker version bump. See the link below for a diff of new changes:\n', compare_url + ' \n'])
elif repo == 'binderhub':
compare_url = 'https://github.com/jupyterhub/binderhub/compare/{}...{}'.format(
commit_info['binderhub']['live'],
commit_info['binderhub']['latest'])
# use var fname from editing step
subprocess.check_call(['git', 'add', fname])
if repo == 'repo2docker':
commit_message = 'repo2docker: https://github.com/jupyter/repo2docker/compare/{}...{}'.format(
commit_info['repo2docker']['live'],commit_info['repo2docker']['latest'])
elif repo == 'binderhub':
commit_message = 'binderhub: https://github.com/jupyterhub/binderhub/compare/{}...{}'.format(
commit_info['binderhub']['live'], commit_info['binderhub']['latest'])
elif repo == 'binderhub':
with open('mybinder/requirements.yaml', 'r') as f:
requirements_yaml = f.read()
updated_yaml = requirements_yaml.replace(
"version: 0.2.0-{}".format(commit_info[upgrade]['live']),
"version: 0.2.0-{}".format(commit_info[upgrade]['latest']))
fname = 'mybinder/requirements.yaml'
with open(fname, 'w') as f:
f.write(updated_yaml)
if repo == 'repo2docker':
with open('mybinder/values.yaml', 'r') as f:
values_yaml = f.read()
updated_yaml = values_yaml.replace(
"jupyter/repo2docker:{}".format(commit_info[upgrade]['live']),
"jupyter/repo2docker:{}".format(commit_info[upgrade]['latest']))
fname = 'mybinder/values.yaml'
with open(fname, 'w') as f:
f.write(updated_yaml)
os.chdir('mybinder.org-deploy')
subprocess.check_call(['git', 'checkout', '-b', '{}_bump'.format(repo)])
subprocess.check_call(['git', 'clone', 'https://github.com/henchbot/mybinder.org-deploy'])
import os
TOKEN = os.environ.get('HENCHBOT_TOKEN')
for repo in ['binderhub', 'repo2docker']:
if commit_info[repo]['live'] != commit_info[repo]['latest']:
res = requests.post('https://api.github.com/repos/jupyterhub/mybinder.org-deploy/forks',
headers={'Authorization': 'token {}'.format(TOKEN)})
# add to commit_info dictionary
commit_info['repo2docker']['latest'] = r2d_master
print('repo2docker', commit_info['repo2docker']['live'], commit_info['repo2docker']['latest'])
commit_info['binderhub']['latest'] = bh_master
print('binderhub', commit_info['binderhub']['live'], commit_info['binderhub']['latest'])
print(commit_info)
url_helm_chart = 'https://raw.githubusercontent.com/jupyterhub/helm-chart/gh-pages/index.yaml'
helm_chart_yaml = load(requests.get(url_helm_chart).text)
# sort by date created
updates_sorted = sorted(helm_chart_yaml['entries']['binderhub'], key=lambda k: k['created'])
bh_master = updates_sorted[-1]['version'].split('-')[-1]
print(bh_master)