josh_github_graphql/operations/
create_check_run.rs1use anyhow::Context;
2use url::Url;
3
4use josh_github_codegen_graphql::{create_check_run, CreateCheckRun};
5
6use crate::connection::GithubApiConnection;
7
8impl GithubApiConnection {
9 pub async fn create_check_run(
10 &self,
11 head_sha: &git2::Oid,
12 name: &str,
13 repository_id: &str,
14 status: create_check_run::RequestableCheckStatusState,
15 conclusion: create_check_run::CheckConclusionState,
16 details_url: &Url,
17 ) -> anyhow::Result<String> {
18 let variables = create_check_run::Variables {
19 input: create_check_run::CreateCheckRunInput {
20 actions: None,
21 client_mutation_id: None,
22 completed_at: None,
23 conclusion: Some(conclusion),
24 details_url: Some(details_url.clone()),
25 external_id: None,
26 head_sha: head_sha.to_string(),
27 name: name.to_string(),
28 output: None,
29 repository_id: repository_id.to_string(),
30 started_at: None,
31 status: Some(status),
32 },
33 };
34
35 let response = self.make_request::<CreateCheckRun>(variables).await?;
36
37 Ok(response
38 .create_check_run
39 .context("Could not create checkrun")?
40 .check_run
41 .context("Could not create checkrun")?
42 .id)
43 }
44}