Skip to content

Commit 12fa5d2

Browse files
committed
Add workflow_run_job and repo_git_trees GitHub methods
1 parent 51616b1 commit 12fa5d2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/github.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,28 @@ impl GithubClient {
232232
.context("failed to retrieve job logs")?;
233233
Ok(String::from_utf8_lossy(&body).to_string())
234234
}
235+
236+
pub async fn workflow_run_job(
237+
&self,
238+
repo: &IssueRepository,
239+
job_id: u128,
240+
) -> anyhow::Result<WorkflowRunJob> {
241+
let url = format!("{}/actions/jobs/{job_id}", repo.url(&self));
242+
self.json(self.get(&url))
243+
.await
244+
.context("failed to retrive workflow job run details")
245+
}
246+
247+
pub async fn repo_git_trees(
248+
&self,
249+
repo: &IssueRepository,
250+
sha: &str,
251+
) -> anyhow::Result<GitTrees> {
252+
let url = format!("{}/git/trees/{sha}", repo.url(&self));
253+
self.json(self.get(&url))
254+
.await
255+
.context("failed to retrive git trees")
256+
}
235257
}
236258

237259
#[derive(Debug, serde::Serialize)]
@@ -1240,6 +1262,11 @@ impl IssuesEvent {
12401262
#[derive(Debug, serde::Deserialize)]
12411263
struct PullRequestEventFields {}
12421264

1265+
#[derive(Debug, serde::Deserialize)]
1266+
pub struct WorkflowRunJob {
1267+
pub head_sha: String,
1268+
}
1269+
12431270
#[derive(Clone, Debug, serde::Deserialize)]
12441271
pub struct CommitBase {
12451272
pub sha: String,
@@ -2829,6 +2856,12 @@ pub struct GitTreeObject {
28292856
pub sha: String,
28302857
}
28312858

2859+
#[derive(Debug, serde::Deserialize)]
2860+
pub struct GitTrees {
2861+
pub sha: String,
2862+
pub tree: Vec<GitTreeEntry>,
2863+
}
2864+
28322865
#[derive(Debug, serde::Serialize, serde::Deserialize)]
28332866
pub struct GitTreeEntry {
28342867
pub path: String,

0 commit comments

Comments
 (0)