ClickHouse/tests/ci/get_robot_token.py
2021-10-20 13:31:48 +03:00

15 lines
426 B
Python

#!/usr/bin/env python3
import os
from github import Github
def get_best_robot_token(token_prefix_env_name="ROBOT_TOKEN_", total_tokens=4):
tokens = {}
for i in range(total_tokens):
token_name = token_prefix_env_name + str(i)
token = os.getenv(token_name)
gh = Github(token)
rest, _ = gh.rate_limiting
tokens[token] = rest
return max(tokens.items(), key=lambda x: x[1])[0]