Exemple #1
0
def publish_clean(build_only, build_publish_ecr_only, publish_helm_only, repo,
                  git_ref, init_submodules):
    g = Git()
    git_account = load_git_configs()["account"]
    repo = repo or ProjectConf().name
    git_url = f"[email protected]:{git_account}/{repo}.git"
    ref = git_ref or g.get_full_hash()
    with tempfile.TemporaryDirectory() as tmpdirname:
        try:
            g.clone(git_url, tmpdirname)
        except subprocess.CalledProcessError:
            logging.warn(f"Could not clone repo {git_url}. Does it exist?")
            return
        try:
            g.checkout(tmpdirname, ref)
        except subprocess.CalledProcessError:
            logging.warn(
                f"Could not checkout to ref {ref} in repo {git_url}. Have you pushed it to remote?"
            )
            return
        if init_submodules:
            try:
                g.init_submodules(tmpdirname)
            except subprocess.CalledProcessError:
                logging.warn(
                    "Could not initialize submodules. Make sure you use ssh urls in"
                    " the .gitmodules folder and double check your credentials."
                )
                return
        with working_directory(tmpdirname):
            publish(build_only, build_publish_ecr_only, publish_helm_only)