Skip to content

Commit

Permalink
Add actions API methods for working with self-hosted runners (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
samkearney authored Nov 3, 2023
1 parent cc559b2 commit 184791c
Show file tree
Hide file tree
Showing 10 changed files with 1,223 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/list_org_self_hosted_runners.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use octocrab::Octocrab;

#[tokio::main]
async fn main() -> octocrab::Result<()> {
// Note: this token must have the `admin:org` scope. An alternative use case
// may be to authenticate as a GitHub App. See github_app_authentication.rs
// for that.
let token = std::env::var("GITHUB_TOKEN").expect("GITHUB_TOKEN env variable is required");

let octocrab = Octocrab::builder().personal_token(token).build()?;

let runners = octocrab
.actions()
.list_org_self_hosted_runners("my-org")
.per_page(100)
.send()
.await?;

for runner in runners {
println!("ID {}:", runner.id);
println!(" Name:\t{}", runner.name);
println!(" OS:\t\t{}", runner.os);
println!(" Status:\t{}", runner.status);
println!(" Busy:\t{}", runner.busy);
print!(" Labels:\t[");
for (index, label) in runner.labels.iter().enumerate() {
print!("\"{}\"", label.name);
if index != runner.labels.len() - 1 {
print!(", ");
}
}
println!("]");
}

Ok(())
}
Loading

0 comments on commit 184791c

Please sign in to comment.