-
-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add actions API methods for working with self-hosted runners (#483)
- Loading branch information
1 parent
cc559b2
commit 184791c
Showing
10 changed files
with
1,223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} |
Oops, something went wrong.