Fix CI/CD in tags #1703

This commit is contained in:
Max Andreev
2022-09-05 16:40:54 +03:00
committed by GitHub
parent 8d8481b17f
commit b7a6d18186
4 changed files with 30 additions and 17 deletions

View File

@@ -20,7 +20,10 @@ def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--event_file", help="Current GitHub event file", required=True)
parser.add_argument(
"--is_pull", help="Is it Pull Request", default=False, action="store_true"
"--type",
help="Event file type",
required=True,
choices=["pull", "tag", "other"],
)
args = parser.parse_args()
return args
@@ -38,13 +41,17 @@ def get_commit_json(event):
def get_details(event, args):
data = {}
current_time = datetime.datetime.utcnow().date()
if args.is_pull:
if args.type == "pull":
commit_json = get_commit_json(event)
data["commit_comment"] = shlex.quote(commit_json[-1]["commit"]["message"])
data["commit_hash"] = commit_json[-1]["sha"]
ref = event["pull_request"]["head"]["ref"]
data["pull_id"] = event["pull_request"]["number"]
data["pull_name"] = shlex.quote(event["pull_request"]["title"])
elif args.type == "tag":
data["commit_comment"] = shlex.quote(event["head_commit"]["message"])
data["commit_hash"] = event["head_commit"]["id"]
ref = event["ref"]
else:
data["commit_comment"] = shlex.quote(event["commits"][-1]["message"])
data["commit_hash"] = event["commits"][-1]["id"]
@@ -78,7 +85,7 @@ def add_envs(data, env_file, args):
add_env("BRANCH_NAME", data["branch_name"], env_file)
add_env("DIST_SUFFIX", data["suffix"], env_file)
add_env("WORKFLOW_BRANCH_OR_TAG", data["branch_name"], env_file)
if args.is_pull:
if args.type == "pull":
add_env("PULL_ID", data["pull_id"], env_file)
add_env("PULL_NAME", data["pull_name"], env_file)