mirror of
https://github.com/Noratrieb/does-it-build.git
synced 2026-01-14 10:25:01 +01:00
Add notifications for target maintainers (#10)
This adds a feature where maintainers can add themselves to an array in the source to receive notifications whenever the target fails. The way this works is via GitHub, I created a new repository https://github.com/Noratrieb/does-it-build-notifications where an app will create issues that ping the respective users. This is the easiest option for me and also fits nicely into people's workflows on GitHub. Whenever a target fails, an issue is created for it. This issue is kept open (with a new comment every day that it continues to fail), and then closed when the target builds again.
This commit is contained in:
parent
112420d224
commit
e4c69f17be
12 changed files with 784 additions and 13 deletions
39
src/github.rs
Normal file
39
src/github.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use color_eyre::{eyre::Context, Result};
|
||||
use octocrab::issues;
|
||||
|
||||
pub struct GitHubClient {
|
||||
pub send_pings: bool,
|
||||
owner: String,
|
||||
repo: String,
|
||||
pub client: octocrab::Octocrab,
|
||||
}
|
||||
|
||||
impl GitHubClient {
|
||||
pub async fn new(
|
||||
send_pings: bool,
|
||||
client: octocrab::Octocrab,
|
||||
owner: String,
|
||||
repo: String,
|
||||
) -> Result<Self> {
|
||||
let installation = client
|
||||
.apps()
|
||||
.get_repository_installation(&owner, &repo)
|
||||
.await
|
||||
.wrap_err_with(|| format!("getting installation for {owner}/{repo}"))?;
|
||||
|
||||
let client = client
|
||||
.installation(installation.id)
|
||||
.wrap_err("getting client for installation")?;
|
||||
|
||||
Ok(Self {
|
||||
send_pings,
|
||||
owner,
|
||||
repo,
|
||||
client,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn issues(&self) -> issues::IssueHandler<'_> {
|
||||
self.client.issues(&self.owner, &self.repo)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue