Skip to content

Commit

Permalink
updated library to version 0.0.3
Browse files Browse the repository at this point in the history
This contains the `get_input` method
  • Loading branch information
Bullrich committed May 27, 2024
1 parent 87addfb commit e9276b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
actions-core = "0.0.2"
actions-github = "0.0.2"
actions-github = "0.0.3"
anyhow = "1.0.86"
octocrab = "0.38.0"
serde = "1.0.202"
Expand Down
20 changes: 11 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
use actions_core::set_output;
use actions_github::context::get_context;
use actions_github::core::get_input;
use anyhow::Result;
use octocrab::Octocrab;

#[tokio::main]
async fn main() {
let ctx = match get_context() {
Ok(context) => context,
Err(error) => panic!("{}", error)
Err(error) => panic!("{}", error),
};
let org: String = ctx.repo.owner;

let team_name: String = actions_core::input("team")
.expect("Missing team name")
.parse()
.expect("Failed to parse team name");
let team_name:String = get_variable("team", true);

let token: String = actions_core::input("ACCESS_TOKEN")
.expect("Missing access token")
.parse()
.expect("Failed to parse access token");
let token:String = get_variable("ACCESS_TOKEN", true);

let crab = Octocrab::builder().personal_token(token).build();
octocrab::initialise(crab.unwrap());
Expand Down Expand Up @@ -52,6 +47,13 @@ struct UserData {
pub avatar: String,
}

fn get_variable(var_name: &str, required:bool) -> String {
match get_input(var_name) {
Ok(variable) => return variable,
Err(err) => panic!("{}", err)
}
}

async fn fetch_team(org: String, team: &String) -> Result<Vec<UserData>> {
let team_data = octocrab::instance()
.teams(org)
Expand Down

0 comments on commit e9276b0

Please sign in to comment.