@@ -11,48 +11,31 @@ let log = Log.from "monorobot"
11
11
let http_server_action addr port config secrets state =
12
12
log#info " monorobot starting" ;
13
13
let ctx = Context. make ~config_filename: config ~secrets_filepath: secrets ?state_filepath:state () in
14
- Lwt_main. run
15
- ( match % lwt Context. refresh_secrets ctx with
16
- | Error e ->
17
- log#error " %s" e;
18
- Lwt. return_unit
19
- | Ok ctx ->
20
- ( match % lwt Context. refresh_state ctx with
21
- | Error e ->
22
- log#error " %s" e;
23
- Lwt. return_unit
24
- | Ok ctx -> Request_handler. run ~ctx ~addr ~port
25
- )
26
- )
14
+ match Context. refresh_secrets ctx with
15
+ | Error e -> log#error " %s" e
16
+ | Ok ctx ->
17
+ match Context. refresh_state ctx with
18
+ | Error e -> log#error " %s" e
19
+ | Ok ctx -> Lwt_main. run (Request_handler. run ~ctx ~addr ~port )
27
20
28
21
(* * In check mode, instead of actually sending the message to slack, we
29
22
simply print it in the console *)
30
23
let check_gh_action file json config secrets state =
31
- Lwt_main. run
32
- begin
33
- match Github. event_of_filename file with
34
- | None ->
35
- log#error " aborting because payload %s is not named properly, named should be KIND.NAME_OF_PAYLOAD.json" file;
36
- Lwt. return_unit
37
- | Some kind ->
38
- let headers = [ " x-github-event" , kind ] in
39
- ( match % lwt Common. get_local_file file with
40
- | Error e ->
41
- log#error " %s" e;
42
- Lwt. return_unit
43
- | Ok body ->
44
- let ctx = Context. make ~config_filename: config ~secrets_filepath: secrets ?state_filepath:state () in
45
- let % lwt () =
46
- if json then
47
- let module Action = Action. Action (Api_remote. Github ) (Api_local. Slack_json ) in
48
- Action. process_github_notification ctx headers body
49
- else
50
- let module Action = Action. Action (Api_remote. Github ) (Api_local. Slack_simple ) in
51
- Action. process_github_notification ctx headers body
52
- in
53
- Lwt. return_unit
54
- )
55
- end
24
+ match Github. event_of_filename file with
25
+ | None ->
26
+ log#error " aborting because payload %s is not named properly, named should be KIND.NAME_OF_PAYLOAD.json" file
27
+ | Some kind ->
28
+ let headers = [ " x-github-event" , kind ] in
29
+ let body = Common. get_local_file file in
30
+ let ctx = Context. make ~config_filename: config ~secrets_filepath: secrets ?state_filepath:state () in
31
+ Lwt_main. run
32
+ ( if json then
33
+ let module Action = Action. Action (Api_remote. Github ) (Api_local. Slack_json ) in
34
+ Action. process_github_notification ctx headers body
35
+ else
36
+ let module Action = Action. Action (Api_remote. Github ) (Api_local. Slack_simple ) in
37
+ Action. process_github_notification ctx headers body
38
+ )
56
39
57
40
let check_slack_action url file =
58
41
let data = Stdio.In_channel. read_all file in
0 commit comments