Newer
Older
#!/usr/bin/env python
from glob import glob
import subprocess as sp
import sys
import time
REGISTRY_URL = 'docker.km3net.de'
def get_changed_dockerfiles():
"""Checks the last Git commit and returns a list of changed Dockefiles"""
diff_cmd = "git diff-tree --no-commit-id --name-only -r HEAD"
child = sp.Popen(diff_cmd, shell=True, stdout=sp.PIPE, stderr=sp.PIPE)
out, _ = child.communicate()
changed_files = [l.decode().rstrip() for l in out.split(b'\n')]
changed_dockerfiles = [f for f in changed_files if f.startswith("base/")]
return changed_dockerfiles
changed_dockerfiles = get_changed_dockerfiles()
n_files = len(changed_dockerfiles)
if n_files == 0:
print("Nothing to do!")
exit(0)
for idx, fname in enumerate(changed_dockerfiles):
REGISTRY_URL, fname))]
if not SKIP_PUSH:
steps.append(("Pushing", "docker push {0}/{1}".format(REGISTRY_URL,
fname)))
else:
print("Skiping push...")
for step, cmd in steps:
print("{} {} '{}'".format(progress, step, fname))
child = sp.Popen(
cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
child.communicate()