-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathhooks.rs
30 lines (29 loc) · 864 Bytes
/
hooks.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use hubcaps::hooks::{HookCreateOptions, WebHookContentType};
use hubcaps::{Credentials, Github};
use std::env;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
pretty_env_logger::init();
let token = env::var("GITHUB_TOKEN")?;
let github = Github::new(
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
Credentials::Token(token),
)?;
let repo = github.repo("softprops", "hubcaps");
let hook = repo
.hooks()
.create(
&HookCreateOptions::web()
.url("http://localhost:8080")
.content_type(WebHookContentType::Json)
.build(),
)
.await;
println!("{:#?}", hook);
let hooks = repo.hooks();
for hook in hooks.list().await? {
println!("{:#?}", hook)
}
Ok(())
}