This commit is contained in:
@@ -2,5 +2,53 @@ __author__ = 'RemiZOffAlex'
|
|||||||
__email__ = 'remizoffalex@mail.ru'
|
__email__ = 'remizoffalex@mail.ru'
|
||||||
|
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import base64
|
||||||
|
|
||||||
|
|
||||||
def handle_git(args):
|
def handle_git(args):
|
||||||
print('args', args)
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user