Files
tools/execute.py

49 lines
1.3 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 14:44:34 +03:00
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))
2025-03-29 01:56:51 +03:00
print('#'*80)
2025-03-29 01:37:26 +03:00
print(sys.argv)
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 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 15:33:02 +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'+'"'
cmd = 'git config --global ' + key + ' ' + value
2025-03-29 15:33:02 +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 15:33:02 +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 + '/' + \
GITHUB_REPOSITORY
2025-03-29 14:46:12 +03:00
print('cmd:', cmd)
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 03:56:34 +03:00
print(f"Encoded string: {base64_string}")
2025-03-29 01:56:51 +03:00
print('#'*80)