Skip to content

Commit

Permalink
add included users list
Browse files Browse the repository at this point in the history
  • Loading branch information
aracho1 committed May 23, 2024
1 parent a2cfca8 commit aebf6f6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
description: "Comma delimited list of user ID's to ignore"
required: true
default: "49699333"
github-included-users:
description: "Comma delimited list of user ID's to show"
required: false
default: ""
github-ignored-labels:
description: "Comma delimited list of label names to ignore"
required: true
Expand All @@ -32,6 +36,7 @@ runs:
GITHUB_REPOSITORIES: ${{ inputs.github-repositories }}
GITHUB_TOKEN: ${{ inputs.github-token }}
GITHUB_IGNORED_USERS: ${{ inputs.github-ignored-users }}
GITHUB_INCLUDED_USERS: ${{ inputs.github-included-users }}
GITHUB_IGNORED_LABELS: ${{ inputs.github-ignored-labels }}
GOOGLE_WEBHOOK_URL: ${{ inputs.google-webhook-url }}
SHOW_PR_AGE: ${{ inputs.show-pr-age }}
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async fn scan_repository(
repository_name: String,
github_token: &String,
ignored_users: &Vec<&str>,
included_users: &Vec<&str>,
ignored_labels: &Vec<&str>,
) -> Result<Vec<GithubPullRequest>, Error> {
info!("Starting PR scan of {}", repository_name);
Expand Down Expand Up @@ -51,6 +52,18 @@ async fn scan_repository(
continue;
}

if !included_users.contains(&pull_request.user().id().to_string().as_str()) {
info!("included users: {:?}", included_users);
info!(
"Ignoring PR {}({}) as it was raised by a user not included in the only_users list {}({})",
pull_request.id(),
pull_request.title(),
pull_request.user().id(),
pull_request.user().login()
);
continue;
}

let mut has_ignore_label = false;

for label in pull_request.labels() {
Expand Down Expand Up @@ -113,6 +126,8 @@ async fn main() -> Result<(), Error> {
env::var("GOOGLE_WEBHOOK_URL").context("GOOGLE_WEBHOOK_URL must be set")?;
let ignored_users: String = env::var("GITHUB_IGNORED_USERS").unwrap_or("".to_string());
let ignored_users: Vec<&str> = ignored_users.split(",").collect();
let included_users: String = env::var("GITHUB_INCLUDED_USERS").unwrap_or("".to_string());
let included_users: Vec<&str> = included_users.split(",").collect();
let ignored_labels: String = env::var("GITHUB_IGNORED_LABELS").unwrap_or("".to_string());
let ignored_labels: Vec<&str> = ignored_labels.split(",").collect();
let show_pr_age: bool = env::var("SHOW_PR_AGE")
Expand All @@ -127,6 +142,7 @@ async fn main() -> Result<(), Error> {
repository.to_string(),
&github_token,
&ignored_users,
&included_users,
&ignored_labels,
)
.await?,
Expand Down

0 comments on commit aebf6f6

Please sign in to comment.