Files
tools/execute.py

40 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python
import os
import sys
print('EXECUTE')
ACTIONS_RUNTIME_TOKEN = os.getenv('ACTIONS_RUNTIME_TOKEN')
GITHUB_SERVER_URL = os.getenv('GITHUB_SERVER_URL')
GITHUB_REPOSITORY = os.getenv('GITHUB_REPOSITORY')
print('GITHUB_SERVER_URL:', GITHUB_SERVER_URL)
print('GITHUB_REPOSITORY:', GITHUB_REPOSITORY)
print(ACTIONS_RUNTIME_TOKEN)
print(len(ACTIONS_RUNTIME_TOKEN))
print('#'*80)
print(sys.argv)
import base64
sample_string = "x-access-token:" + ACTIONS_RUNTIME_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")
config = 'http.'+GITHUB_SERVER_URL+'/.extraheader="'+base64_string+'"'
cmd = 'git config --global ' + config
os.system(cmd)
config = 'url.'+GITHUB_SERVER_URL+'/.insteadOf="git'+'codex.r10x.net+'"'
cmd = 'git config --global ' + config
os.system(cmd)
cmd = 'git config list '
os.system(cmd)
cmd = 'git clone ' + \
GITHUB_SERVER_URL + '/' + \
GITHUB_REPOSITORY
print('cmd:', cmd)
os.system(cmd)
print(f"Encoded string: {base64_string}")
print('#'*80)