def _deploy_git(self): if IS_DEVELOPMENT: return print(title("Deploy to git remote") + "\n") try: remote_path = git_remote_path() subprocess.check_call(f""" git push https://{conf.github_token}@{remote_path} HEAD:master &> /dev/null """, shell=True) print("Sucessufly push on git remote") except: sys.exit("Error: Failed to push some refs to 'https://%s'" % git_remote_path())
def _check_github_token(): valid = False user = git_remote_path().split("/")[1] response = output("curl -su %s:%s https://api.github.com/user" % (user, conf.github_token)) content = json.loads(response) if "login" in content: valid = True validate( error= "An error occured while trying to connect to your github repository with your encrypted token.\nPlease make sure that your token is working.", target="github token api", valid=valid)
def _replace_html_variables(self): remote_path = 'https://' + git_remote_path().rstrip('.git') for line in edit_file(paths.mirror + "/index.html"): line = line.replace("$content", self.html_table_tbody) line = line.replace("$path", conf.url) line = line.replace("$database", conf.db) line = line.replace("$remote_path", remote_path) line = line.replace("images/logo.png", "data:image/png;base64," + get_base64(paths.www + "/images/logo.png")) line = line.replace("images/background.png", "data:image/png;base64," + get_base64(paths.www + "/images/background.png")) if line.strip() == "<link rel=\"stylesheet\" href=\"css/main.css\">": line = "<style type=\"text/css\">" line += get_compressed_file(paths.www + "/css/main.css") line += "</style>" print(line)
""" import os from utils.process import git_remote_path # Bot version (<major>.<minor>.<month>.<monthly commit>) # To get the monthly commit, you need to execute # git rev-list --count HEAD --since="2019-07-01" VERSION = "1.0.7.61" # Upstream repository UPSTREAM_REPOSITORY = "https://github.com/unix-development/build-your-own-archlinux-repository" # Current repository CURRENT_REPOSITORY = "https://" + git_remote_path().rstrip(".git") # Check if it's upstream repository IS_DEVELOPMENT = (CURRENT_REPOSITORY is UPSTREAM_REPOSITORY) # Define if it's Travis-CI IS_TRAVIS = ("TRAVIS" in os.environ and os.environ["TRAVIS"] != "") # Content allowed in repository.json ALLOWED_CONFIGS = ("database", "url", "github.token", "ssh.port", "ssh.user", "ssh.host", "ssh.path", "auto-update") # Alias configs for repository.json ALIAS_CONFIGS = ("db", "url", "github_token", "ssh_port", "ssh_user", "ssh_host", "ssh_path", "auto_update")
def _get_remote_path(self): remote_path = git_remote_path() host = remote_path[:remote_path.find("/") + 1] return remote_path.rstrip('.git').strip(host)