Skip to content

Instantly share code, notes, and snippets.

@vsudilov
Last active August 29, 2015 14:25
Show Gist options
  • Save vsudilov/e61a170ae8d55f6efc55 to your computer and use it in GitHub Desktop.
Save vsudilov/e61a170ae8d55f6efc55 to your computer and use it in GitHub Desktop.
Fetch latest commit from target repo on github, check if that image is on dockerhub
import requests
import argparse
API_ENDPOINT = "https://api.github.com/repos/adsabs/{repo}/branches/master"
DOCKERHUB = "https://registry.hub.docker.com/v1/repositories/adsabs/{repo}/tags"
parser = argparse.ArgumentParser()
parser.add_argument(
"--repos",
nargs='*',
dest='repos',
)
args = parser.parse_args()
for repo in args.repos:
hash = requests.get(API_ENDPOINT.format(repo=repo)).json()['commit']['sha']
tags = [i['name'] for i in requests.get(DOCKERHUB.format(repo=repo)).json()]
print "{}\t\t{}\t\t{}".format(repo, hash, hash in tags)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment