Skip to content

Commit

Permalink
updated to use context library
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich committed May 24, 2024
1 parent d9d0b90 commit 87addfb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"

[dependencies]
actions-core = "0.0.2"
actions-github = "0.0.2"
anyhow = "1.0.86"
octocrab = "0.38.0"
serde = "1.0.202"
Expand Down
17 changes: 8 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use std::env;

use actions_core::set_output;
use actions_github::context::get_context;
use anyhow::Result;
use octocrab::Octocrab;

#[tokio::main]
async fn main() {
let org_input = actions_core::input("organization");
let org: String = match org_input {
Ok(v) => v,
Err(_) => env::var("GITHUB_REPOSITORY").unwrap(),
let ctx = match get_context() {
Ok(context) => context,
Err(error) => panic!("{}", error)
};
let org: String = ctx.repo.owner;

let team_name: String = actions_core::input("team")
.expect("Missing team name")
Expand All @@ -25,12 +24,12 @@ async fn main() {
let crab = Octocrab::builder().personal_token(token).build();
octocrab::initialise(crab.unwrap());

let team = fetch_team(org, team_name).await.unwrap();
let team = fetch_team(org, &team_name).await.unwrap();

if team.is_empty() {
panic!(
"No users where found while searching for the team {}",
"opstooling"
&team_name
);
}

Expand All @@ -53,7 +52,7 @@ struct UserData {
pub avatar: String,
}

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

0 comments on commit 87addfb

Please sign in to comment.