From 1fe3acc1422b09db27d179db05331a763b1db8a6 Mon Sep 17 00:00:00 2001 From: iximeow Date: Mon, 26 Dec 2022 00:21:32 +0000 Subject: let build runners indicate restricted interest --- src/main.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 56aca01..56ad88b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,7 +43,7 @@ enum GithubHookError { #[derive(Debug)] enum GithubEvent { - Push { tip: String, repo_name: String, head_commit: serde_json::Map }, + Push { tip: String, repo_name: String, head_commit: serde_json::Map, pusher: serde_json::Map }, Other {} } @@ -73,17 +73,23 @@ fn parse_push_event(body: serde_json::Value) -> Result, owner: String, repo: String, event: GithubEvent) -> impl IntoResponse { - let (sha, repo, head_commit) = if let GithubEvent::Push { tip, repo_name, head_commit } = event { - (tip, repo_name, head_commit) + let (sha, repo, head_commit, pusher) = if let GithubEvent::Push { tip, repo_name, head_commit, pusher } = event { + (tip, repo_name, head_commit, pusher) } else { panic!("process push event on non-push event"); }; - println!("handling push event to {}/{}: sha {} in repo {}, {:?}", owner, repo, sha, repo, head_commit); + println!("handling push event to {}/{}: sha {} in repo {}, {:?}\n pusher: {:?}", owner, repo, sha, repo, head_commit, pusher); // push event is in terms of a ref, but we don't know if it's a new commit (yet). // in terms of CI jobs, we care mainly about new commits. @@ -115,7 +121,13 @@ async fn process_push_event(ctx: Arc, owner: String, repo: String, event: } }; - let job_id = ctx.new_job(remote_id, &sha).unwrap(); + let pusher_email = pusher + .get("email") + .expect("has email") + .as_str() + .expect("is str"); + + let job_id = ctx.new_job(remote_id, &sha, Some(pusher_email)).unwrap(); let notifiers = ctx.notifiers_by_repo(repo_id).expect("can get notifiers"); -- cgit v1.1