@@ -20,7 +20,10 @@ def parse_args():
20
20
parser = argparse .ArgumentParser ()
21
21
parser .add_argument ("--event_file" , help = "Current GitHub event file" , required = True )
22
22
parser .add_argument (
23
- "--is_pull" , help = "Is it Pull Request" , default = False , action = "store_true"
23
+ "--type" ,
24
+ help = "Event file type" ,
25
+ required = True ,
26
+ choices = ["pull" , "tag" , "other" ],
24
27
)
25
28
args = parser .parse_args ()
26
29
return args
@@ -38,13 +41,17 @@ def get_commit_json(event):
38
41
def get_details (event , args ):
39
42
data = {}
40
43
current_time = datetime .datetime .utcnow ().date ()
41
- if args .is_pull :
44
+ if args .type == "pull" :
42
45
commit_json = get_commit_json (event )
43
46
data ["commit_comment" ] = shlex .quote (commit_json [- 1 ]["commit" ]["message" ])
44
47
data ["commit_hash" ] = commit_json [- 1 ]["sha" ]
45
48
ref = event ["pull_request" ]["head" ]["ref" ]
46
49
data ["pull_id" ] = event ["pull_request" ]["number" ]
47
50
data ["pull_name" ] = shlex .quote (event ["pull_request" ]["title" ])
51
+ elif args .type == "tag" :
52
+ data ["commit_comment" ] = shlex .quote (event ["head_commit" ]["message" ])
53
+ data ["commit_hash" ] = event ["head_commit" ]["id" ]
54
+ ref = event ["ref" ]
48
55
else :
49
56
data ["commit_comment" ] = shlex .quote (event ["commits" ][- 1 ]["message" ])
50
57
data ["commit_hash" ] = event ["commits" ][- 1 ]["id" ]
@@ -78,7 +85,7 @@ def add_envs(data, env_file, args):
78
85
add_env ("BRANCH_NAME" , data ["branch_name" ], env_file )
79
86
add_env ("DIST_SUFFIX" , data ["suffix" ], env_file )
80
87
add_env ("WORKFLOW_BRANCH_OR_TAG" , data ["branch_name" ], env_file )
81
- if args .is_pull :
88
+ if args .type == "pull" :
82
89
add_env ("PULL_ID" , data ["pull_id" ], env_file )
83
90
add_env ("PULL_NAME" , data ["pull_name" ], env_file )
84
91
0 commit comments