ClickHouse/tests/ci/cherry_pick.py

40 lines
1.3 KiB
Python
Raw Normal View History

2021-11-08 14:30:27 +00:00
#!/usr/bin/env python3
2021-11-08 14:45:19 +00:00
import sys
2021-11-08 14:30:27 +00:00
import logging
import os
import subprocess
2021-11-08 14:45:19 +00:00
2021-11-09 17:56:44 +00:00
from get_robot_token import get_parameter_from_ssm
2021-11-08 14:30:27 +00:00
from ssh import SSHKey
from cherry_pick_utils.backport import Backport
from cherry_pick_utils.cherrypick import CherryPick
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
2021-11-09 11:10:57 +00:00
repo_path = os.path.join(os.getenv("GITHUB_WORKSPACE", os.path.abspath("../../")))
2021-11-08 14:30:27 +00:00
temp_path = os.path.join(os.getenv("TEMP_PATH"))
if not os.path.exists(temp_path):
os.makedirs(temp_path)
sys.path.append(os.path.join(repo_path, "utils/github"))
with SSHKey("ROBOT_CLICKHOUSE_SSH_KEY"):
2021-11-09 17:56:44 +00:00
token = get_parameter_from_ssm("github_robot_token_1")
2021-11-08 14:30:27 +00:00
bp = Backport(token, os.environ.get("REPO_OWNER"), os.environ.get("REPO_NAME"), os.environ.get("REPO_TEAM"))
def cherrypick_run(token, pr, branch):
return CherryPick(token,
os.environ.get("REPO_OWNER"), os.environ.get("REPO_NAME"),
os.environ.get("REPO_TEAM"), pr, branch
).execute(repo_path, False)
try:
bp.execute(repo_path, 'origin', None, cherrypick_run)
except subprocess.CalledProcessError as e:
logging.error(e.output)