@@ -18,28 +18,34 @@ sub read_settings ($self, $settings) {
1818 return 1;
1919}
2020
21- sub report_status_to_git ($self , $params , $scheduled_product_id , $callback = undef ) {
21+ sub add_params ($self , $params , $scheduled_product_id ) {
2222 $params -> {context } //= ' openqa' ;
2323 $params -> {description } //= ' openQA test run' ;
2424 my $base_url = $self -> base_url;
2525 $params -> {target_url } //= " $base_url /admin/productlog?id=$scheduled_product_id "
2626 if $scheduled_product_id && $base_url ;
27+ }
2728
28- my $url = Mojo::URL -> new ($self -> statuses_url);
29+ sub create_request ($self , $params ) {
2930 my $app = $self -> app;
3031 my $ua = $app -> ua;
32+ my $url = Mojo::URL-> new($self -> statuses_url);
3133 my $tx = $ua -> build_tx(POST => $url );
3234 my $req = $tx -> req;
33- my $headers = $req -> headers;
34- my $github_token = $app -> config-> {secrets }-> {github_token };
3535 my $json = encode_json($params );
3636 $req -> body($json );
37+ my $headers = $req -> headers;
3738 $headers -> content_type(' application/json' );
3839 $headers -> content_length(length $json );
39- $headers -> header(Accept => ' application/vnd.github+json' );
40- $headers -> header(Authorization => " Bearer $github_token " );
41- $headers -> header(' X-GitHub-Api-Version' => ' 2022-11-28' );
42- $ua -> start($tx , $callback );
40+
41+ return $tx ;
42+ }
43+
44+ sub report_status_to_git ($self , $params , $scheduled_product_id , $callback = undef ) {
45+ $self -> add_params($params , $scheduled_product_id );
46+
47+ my $tx = $self -> create_request($params );
48+ $self -> app-> ua-> start($tx , $callback );
4349 return $tx ;
4450}
4551
0 commit comments