Add configurable event publishing
This commit is contained in:
@@ -18,14 +18,38 @@ use std::{collections::HashMap, fmt, fs::File, io::BufReader};
|
||||
|
||||
use anyhow::Context;
|
||||
use matrix_sdk::ruma::{OwnedRoomOrAliasId, OwnedUserId, RoomOrAliasId, UserId};
|
||||
use regex::Regex;
|
||||
use serde::de;
|
||||
|
||||
use crate::event::{IssueAction, MergeRequestAction, PipelineStatus};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(tag = "name", rename_all = "snake_case")]
|
||||
pub enum PublishEvent {
|
||||
Push {
|
||||
#[serde(default)]
|
||||
#[serde(with = "serde_regex")]
|
||||
branches: Option<Vec<Regex>>,
|
||||
},
|
||||
TagPush,
|
||||
Issues {
|
||||
actions: Option<Vec<IssueAction>>,
|
||||
},
|
||||
MergeRequest {
|
||||
actions: Option<Vec<MergeRequestAction>>,
|
||||
},
|
||||
Pipeline {
|
||||
statuses: Option<Vec<PipelineStatus>>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RepoConfig {
|
||||
pub token: String,
|
||||
#[serde(default)]
|
||||
#[serde(deserialize_with = "deser_optional_room_or_alias_id")]
|
||||
pub room: Option<OwnedRoomOrAliasId>,
|
||||
pub publish_events: Option<Vec<PublishEvent>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -39,6 +63,7 @@ pub struct Config {
|
||||
#[serde(default)]
|
||||
#[serde(deserialize_with = "deser_optional_room_or_alias_id")]
|
||||
pub default_room: Option<OwnedRoomOrAliasId>,
|
||||
pub default_publish_events: Option<Vec<PublishEvent>>,
|
||||
pub repo_configs: HashMap<String, RepoConfig>, // key is repo url without scheme; e.g.
|
||||
// gitlab.xfce.org/xfce/xfdesktop
|
||||
}
|
||||
|
Reference in New Issue
Block a user