forked from softprops/hubcaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deployments.rs
36 lines (31 loc) · 1.07 KB
/
deployments.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
31
32
33
34
35
36
extern crate hyper;
extern crate hubcaps;
extern crate tokio_core;
#[macro_use(quick_main)]
extern crate error_chain;
use std::env;
use tokio_core::reactor::Core;
use hubcaps::{Credentials, Github, Result};
quick_main!(run);
fn run() -> Result<()> {
match env::var("GITHUB_TOKEN").ok() {
Some(token) => {
let mut core = Core::new()?;
let github = Github::new(
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
Some(Credentials::Token(token)),
&core.handle(),
);
let repo = github.repo("softprops", "hubcaps");
let deployments = repo.deployments();
// let deploy = deployments.create(&DeploymentOptions::builder("master")
// .payload("this is the payload".to_owned()).build());
// println!("{:?}", deploy);
for d in core.run(deployments.list(&Default::default()))? {
println!("{:#?}", d)
}
Ok(())
}
_ => Err("example missing GITHUB_TOKEN".into()),
}
}