particle-os-cli/process/drivers/github_driver/event.rs
Gerald Pinder 8ce83ba7ff
refactor: Create SigningDriver and CiDriver (#197)
This also includes a new `login` command. The signing and CI logic is now using the Driver trait system along with a new experimental sigstore signing driver. New static macros have also been created to make implementation management easier for `Command` usage and `Driver` trait implementation calls.

---------

Co-authored-by: xyny <60004820+xynydev@users.noreply.github.com>
2024-08-12 23:52:07 -04:00

44 lines
1.1 KiB
Rust

use std::{fs, path::PathBuf};
use blue_build_utils::{constants::GITHUB_EVENT_PATH, get_env_var};
use miette::{IntoDiagnostic, Result};
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
pub(super) struct Event {
pub repository: EventRepository,
// pub base: Option<EventRefInfo>,
pub head: Option<EventRefInfo>,
#[serde(alias = "ref")]
pub commit_ref: Option<String>,
}
impl Event {
pub fn try_new() -> Result<Self> {
get_env_var(GITHUB_EVENT_PATH)
.map(PathBuf::from)
.and_then(|event_path| {
serde_json::from_str::<Self>(&fs::read_to_string(event_path).into_diagnostic()?)
.into_diagnostic()
})
}
}
#[derive(Debug, Deserialize, Clone)]
pub(super) struct EventRepository {
pub default_branch: String,
pub owner: EventRepositoryOwner,
pub html_url: String,
}
#[derive(Debug, Deserialize, Clone)]
pub(super) struct EventRepositoryOwner {
pub login: String,
}
#[derive(Debug, Deserialize, Clone)]
pub(super) struct EventRefInfo {
#[serde(alias = "ref")]
pub commit_ref: String,
}