mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
releaser: refactor; add func GetGitHubAPIHandler
This commit is contained in:
@@ -62,24 +62,27 @@ def GetListOfArtifacts(argv):
|
|||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
||||||
files = GetListOfArtifacts(sys_argv)
|
def GetGitHubAPIHandler():
|
||||||
|
print("· Get GitHub API handler (authenticate)")
|
||||||
|
|
||||||
|
if "GITHUB_TOKEN" in environ:
|
||||||
print("· Get GitHub API handler (authenticate)")
|
return Github(environ["GITHUB_TOKEN"])
|
||||||
|
elif "INPUT_TOKEN" in environ:
|
||||||
if "GITHUB_TOKEN" in environ:
|
return Github(environ["INPUT_TOKEN"])
|
||||||
gh = Github(environ["GITHUB_TOKEN"])
|
else:
|
||||||
elif "INPUT_TOKEN" in environ:
|
if "GITHUB_USER" not in environ or "GITHUB_PASS" not in environ:
|
||||||
gh = Github(environ["INPUT_TOKEN"])
|
stdout.flush()
|
||||||
else:
|
raise (
|
||||||
if "GITHUB_USER" not in environ or "GITHUB_PASS" not in environ:
|
Exception(
|
||||||
stdout.flush()
|
"Need credentials to authenticate! Please, provide 'GITHUB_TOKEN', 'INPUT_TOKEN', or 'GITHUB_USER' and 'GITHUB_PASS'"
|
||||||
raise (
|
)
|
||||||
Exception(
|
|
||||||
"Need credentials to authenticate! Please, provide 'GITHUB_TOKEN', 'INPUT_TOKEN', or 'GITHUB_USER' and 'GITHUB_PASS'"
|
|
||||||
)
|
)
|
||||||
)
|
return Github(environ["GITHUB_USER"], environ["GITHUB_PASS"])
|
||||||
gh = Github(environ["GITHUB_USER"], environ["GITHUB_PASS"])
|
|
||||||
|
|
||||||
|
files = GetListOfArtifacts(sys_argv)
|
||||||
|
gh = GetGitHubAPIHandler()
|
||||||
|
|
||||||
|
|
||||||
print("· Get Repository handler")
|
print("· Get Repository handler")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user