Skip to content

Commit ba1679a

Browse files
committed
fix check_gh payload and secrets initialization
1 parent 6d428ae commit ba1679a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/notabot.ml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let http_server_action addr port config secrets state =
2121
(** In check mode, instead of actually sending the message to slack, we
2222
simply print it in the console *)
2323
let check_gh_action file json config secrets state =
24-
match Github.event_of_filename file with
24+
match Github.event_of_filename (Caml.Filename.basename file) with
2525
| None ->
2626
log#error "aborting because payload %s is not named properly, named should be KIND.NAME_OF_PAYLOAD.json" file
2727
| Some kind ->
@@ -30,14 +30,18 @@ let check_gh_action file json config secrets state =
3030
| Ok body ->
3131
let headers = [ "x-github-event", kind ] in
3232
let ctx = Context.make ~config_filename:config ~secrets_filepath:secrets ?state_filepath:state () in
33-
Lwt_main.run
34-
( if json then
35-
let module Action = Action.Action (Api_remote.Github) (Api_local.Slack_json) in
36-
Action.process_github_notification ctx headers body
37-
else
38-
let module Action = Action.Action (Api_remote.Github) (Api_local.Slack_simple) in
39-
Action.process_github_notification ctx headers body
40-
)
33+
( match Context.refresh_secrets ctx with
34+
| Error e -> log#error "%s" e
35+
| Ok ctx ->
36+
Lwt_main.run
37+
( if json then
38+
let module Action = Action.Action (Api_remote.Github) (Api_local.Slack_json) in
39+
Action.process_github_notification ctx headers body
40+
else
41+
let module Action = Action.Action (Api_remote.Github) (Api_local.Slack_simple) in
42+
Action.process_github_notification ctx headers body
43+
)
44+
)
4145

4246
let check_slack_action url file =
4347
let data = Stdio.In_channel.read_all file in

0 commit comments

Comments
 (0)