From 28bf0614349cb8eef964f964509e44302d35fd78 Mon Sep 17 00:00:00 2001 From: RemiZOffAlex Date: Sat, 18 Oct 2025 23:15:23 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20executor/cli/git.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- executor/cli/git.py | 50 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/executor/cli/git.py b/executor/cli/git.py index 24c55c0..d3a826e 100644 --- a/executor/cli/git.py +++ b/executor/cli/git.py @@ -2,5 +2,53 @@ __author__ = 'RemiZOffAlex' __email__ = 'remizoffalex@mail.ru' +import os +import sys +import base64 + + def handle_git(args): - print('args', args) \ No newline at end of file + DEBUG = True + ACTIONS_RUNTIME_TOKEN = os.getenv('ACTIONS_RUNTIME_TOKEN') + INPUT_TOKEN = os.getenv('INPUT_TOKEN') + GITHUB_SERVER_URL = os.getenv('GITHUB_SERVER_URL') + GITHUB_REPOSITORY = os.getenv('GITHUB_REPOSITORY') + GITHUB_REF = os.getenv('GITHUB_REF') + GITHUB_REF_NAME = os.getenv('GITHUB_REF_NAME') + + def escape(text): + return '"' + text + '"' + + + def exec_cmd(cmd): + result = os.popen(cmd) + print(result.read()) + + cmd = 'git init' + exec_cmd(cmd) + + sample_string = "x-access-token:" + ACTIONS_RUNTIME_TOKEN + sample_string = "x-access-token:" + INPUT_TOKEN + sample_string_bytes = sample_string.encode("utf-8") + + base64_bytes = base64.b64encode(sample_string_bytes) + base64_string = 'AUTHORIZATION: basic ' + base64_bytes.decode("utf-8") + + key = 'http.'+GITHUB_SERVER_URL+'/.extraheader' + value = base64_string + cmd = 'git config set --local ' + key + ' ' + escape(value) + exec_cmd(cmd) + + key = 'url.https://'+ACTIONS_RUNTIME_TOKEN+':x-oauth-basic@codex.r10x.net'+'/.insteadOf' + value = 'git@"'+base64_string+'"' + cmd = 'git config set --local ' + escape(key) + ' ' + escape(GITHUB_SERVER_URL) + exec_cmd(cmd) + + cmd = 'git remote add origin ' + GITHUB_SERVER_URL + '/' + GITHUB_REPOSITORY + exec_cmd(cmd) + + cmd = 'git fetch --progress --depth 1 origin ' + GITHUB_REF + exec_cmd(cmd) + + cmd = 'git checkout ' + GITHUB_REF_NAME + exec_cmd(cmd)