Files
tools/execute.py

57 lines
1.6 KiB
Python
Raw Normal View History

2025-03-29 01:37:26 +03:00
#!/usr/bin/env python
2025-03-29 03:47:20 +03:00
import os
2025-03-29 01:37:26 +03:00
import sys
2025-03-29 01:56:51 +03:00
print('EXECUTE')
2025-03-29 22:45:58 +03:00
print(sys.argv)
2025-03-29 22:24:58 +03:00
# for key, value in os.environ.items():
# print(f"{key}={value}")
2025-03-29 14:44:34 +03:00
ACTIONS_RUNTIME_TOKEN = os.getenv('ACTIONS_RUNTIME_TOKEN')
2025-03-29 21:50:22 +03:00
INPUT_TOKEN = os.getenv('INPUT_TOKEN')
2025-03-29 14:44:34 +03:00
GITHUB_SERVER_URL = os.getenv('GITHUB_SERVER_URL')
GITHUB_REPOSITORY = os.getenv('GITHUB_REPOSITORY')
2025-03-29 01:56:51 +03:00
print('#'*80)
2025-03-29 03:56:34 +03:00
import base64
2025-03-29 14:44:34 +03:00
sample_string = "x-access-token:" + ACTIONS_RUNTIME_TOKEN
2025-03-29 21:49:36 +03:00
sample_string = "x-access-token:" + INPUT_TOKEN
2025-03-29 03:56:34 +03:00
sample_string_bytes = sample_string.encode("utf-8")
base64_bytes = base64.b64encode(sample_string_bytes)
base64_string = 'AUTHORIZATION: basic ' + base64_bytes.decode("utf-8")
2025-03-29 15:09:04 +03:00
key = 'http.'+GITHUB_SERVER_URL+'/.extraheader'
value = '"'+base64_string+'"'
cmd = 'git config --global ' + key + ' ' + value
2025-03-29 21:46:51 +03:00
# result = os.popen(cmd)
# print('result:' , result.read())
2025-03-29 15:09:04 +03:00
key = 'url.'+GITHUB_SERVER_URL+'/.insteadOf'
value = '"git@'+'codex.r10x.net'+'"'
2025-03-29 15:36:11 +03:00
cmd = 'git config --global ' + key + ' ' + GITHUB_SERVER_URL
2025-03-29 21:46:51 +03:00
# result = os.popen(cmd)
# print('result:' , result.read())
2025-03-29 15:09:04 +03:00
2025-03-29 14:58:59 +03:00
cmd = 'git config list '
2025-03-29 21:46:51 +03:00
# result = os.popen(cmd)
# print('result:' , result.read())
2025-03-29 15:09:04 +03:00
2025-03-29 14:58:59 +03:00
cmd = 'git clone ' + \
2025-03-29 14:44:34 +03:00
GITHUB_SERVER_URL + '/' + \
2025-03-29 22:25:41 +03:00
GITHUB_REPOSITORY + ' ' + os.getcwd()
2025-03-29 14:46:12 +03:00
print('cmd:', cmd)
2025-03-29 22:24:58 +03:00
print('pwd', os.getcwd())
2025-03-29 15:33:02 +03:00
result = os.popen(cmd)
print('result:' , result.read())
2025-03-29 03:59:57 +03:00
2025-03-29 22:24:58 +03:00
# cmd = 'git clone ' + \
# 'https://' + sample_string + '@codex.r10x.net' + '/' + \
# GITHUB_REPOSITORY
# print('cmd:', cmd)
# result = os.popen(cmd)
# print('result:' , result.read())
2025-03-29 15:49:41 +03:00
2025-03-29 03:56:34 +03:00
print(f"Encoded string: {base64_string}")
2025-03-29 01:56:51 +03:00
print('#'*80)