+17
-19
@@ -6,6 +6,7 @@ import base64
|
|||||||
|
|
||||||
# for key, value in os.environ.items():
|
# for key, value in os.environ.items():
|
||||||
# print(f"{key}={value}")
|
# print(f"{key}={value}")
|
||||||
|
DEBUG = True
|
||||||
ACTIONS_RUNTIME_TOKEN = os.getenv('ACTIONS_RUNTIME_TOKEN')
|
ACTIONS_RUNTIME_TOKEN = os.getenv('ACTIONS_RUNTIME_TOKEN')
|
||||||
INPUT_TOKEN = os.getenv('INPUT_TOKEN')
|
INPUT_TOKEN = os.getenv('INPUT_TOKEN')
|
||||||
GITHUB_SERVER_URL = os.getenv('GITHUB_SERVER_URL')
|
GITHUB_SERVER_URL = os.getenv('GITHUB_SERVER_URL')
|
||||||
@@ -16,13 +17,17 @@ GITHUB_REF_NAME = os.getenv('GITHUB_REF_NAME')
|
|||||||
def escape(text):
|
def escape(text):
|
||||||
return '"' + text + '"'
|
return '"' + text + '"'
|
||||||
|
|
||||||
|
|
||||||
|
def exec_cmd(cmd):
|
||||||
|
print(cmd)
|
||||||
|
result = os.popen(cmd)
|
||||||
|
print(result.read())
|
||||||
|
|
||||||
cmd = 'git init'
|
cmd = 'git init'
|
||||||
result = os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
print(result.read())
|
|
||||||
|
|
||||||
cmd = 'ls -la'
|
cmd = 'ls -la'
|
||||||
result = os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
print(result.read())
|
|
||||||
|
|
||||||
sample_string = "x-access-token:" + ACTIONS_RUNTIME_TOKEN
|
sample_string = "x-access-token:" + ACTIONS_RUNTIME_TOKEN
|
||||||
sample_string = "x-access-token:" + INPUT_TOKEN
|
sample_string = "x-access-token:" + INPUT_TOKEN
|
||||||
@@ -34,7 +39,7 @@ base64_string = 'AUTHORIZATION: basic ' + base64_bytes.decode("utf-8")
|
|||||||
key = 'http.'+GITHUB_SERVER_URL+'/.extraheader'
|
key = 'http.'+GITHUB_SERVER_URL+'/.extraheader'
|
||||||
value = base64_string
|
value = base64_string
|
||||||
cmd = 'git config set --local ' + key + ' ' + escape(value)
|
cmd = 'git config set --local ' + key + ' ' + escape(value)
|
||||||
result = os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
|
|
||||||
key = 'url.'+GITHUB_SERVER_URL+'/.insteadOf'
|
key = 'url.'+GITHUB_SERVER_URL+'/.insteadOf'
|
||||||
cmd = 'git config set --local ' + escape(key) + ' ' + GITHUB_SERVER_URL
|
cmd = 'git config set --local ' + escape(key) + ' ' + GITHUB_SERVER_URL
|
||||||
@@ -44,32 +49,25 @@ key = 'url.https://'+INPUT_TOKEN+':x-oauth-basic@codex.r10x.net'+'/.insteadOf'
|
|||||||
key = 'url.https://'+ACTIONS_RUNTIME_TOKEN+':x-oauth-basic@codex.r10x.net'+'/.insteadOf'
|
key = 'url.https://'+ACTIONS_RUNTIME_TOKEN+':x-oauth-basic@codex.r10x.net'+'/.insteadOf'
|
||||||
value = 'git@"'+base64_string+'"'
|
value = 'git@"'+base64_string+'"'
|
||||||
cmd = 'git config set --local ' + escape(key) + ' ' + escape(GITHUB_SERVER_URL)
|
cmd = 'git config set --local ' + escape(key) + ' ' + escape(GITHUB_SERVER_URL)
|
||||||
result = os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
|
|
||||||
cmd = 'git remote add origin ' + GITHUB_SERVER_URL + '/' + GITHUB_REPOSITORY
|
cmd = 'git remote add origin ' + GITHUB_SERVER_URL + '/' + GITHUB_REPOSITORY
|
||||||
os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
|
|
||||||
cmd = 'git fetch --progress --depth 1 origin ' + GITHUB_REF
|
cmd = 'git fetch --progress --depth 1 origin ' + GITHUB_REF
|
||||||
result = os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
print(result.read())
|
|
||||||
|
|
||||||
cmd = 'git checkout ' + GITHUB_REF_NAME
|
cmd = 'git checkout ' + GITHUB_REF_NAME
|
||||||
result = os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
print(result.read())
|
|
||||||
|
|
||||||
cmd = 'ls -la'
|
cmd = 'ls -la'
|
||||||
result = os.popen(cmd)
|
exec_cmd(cmd)
|
||||||
print(result.read())
|
|
||||||
|
|
||||||
cmd = 'git config list --local'
|
cmd = 'git config list --local'
|
||||||
print(cmd)
|
exec_cmd(cmd)
|
||||||
result = os.popen(cmd)
|
|
||||||
print(result.read())
|
|
||||||
|
|
||||||
# cmd = 'git config list --global'
|
# cmd = 'git config list --global'
|
||||||
# print(cmd)
|
# exec_cmd(cmd)
|
||||||
# result = os.popen(cmd)
|
|
||||||
# print(result.read())
|
|
||||||
|
|
||||||
# cmd = 'git clone ' + \
|
# cmd = 'git clone ' + \
|
||||||
# GITHUB_SERVER_URL + '/' + \
|
# GITHUB_SERVER_URL + '/' + \
|
||||||
|
|||||||
Reference in New Issue
Block a user