dagger-components/crates/cuddle-ci/src/lib.rs

67 lines
1.9 KiB
Rust
Raw Normal View History

pub mod cli;
pub use cli::*;
pub mod leptos_service;
pub mod node_service;
pub mod rust_lib;
pub mod rust_service;
pub mod cuddle_file;
pub mod cuddle_please;
pub mod cuddle_releaser;
pub mod cuddle_x;
pub mod dagger_middleware;
pub mod drone_templater {
use std::path::PathBuf;
const DRONE_TEMPLATER_IMAGE: &str = "kasperhermansen/drone-templater:main-1711758171";
use async_trait::async_trait;
use crate::MainAction;
pub struct DroneTemplater {
client: dagger_sdk::Query,
template: PathBuf,
}
impl DroneTemplater {
pub fn new(client: dagger_sdk::Query, template: impl Into<PathBuf>) -> Self {
Self {
client: client.pipeline("drone-templater"),
template: template.into(),
}
}
}
#[async_trait]
impl MainAction for DroneTemplater {
async fn execute_main(&self, _ctx: &mut crate::Context) -> eyre::Result<()> {
let src = self.client.host().directory(".cuddle/tmp/");
let drone_host = std::env::var("DRONE_HOST");
let drone_user = std::env::var("DRONE_USER");
let drone_token = std::env::var("DRONE_TOKEN");
let drone_token_secret = client.set_secret("DRONE_TOKEN", drone_token);
self.client
.container()
.from(DRONE_TEMPLATER_IMAGE)
.with_directory("/src/templates", src)
.with_workdir("/src")
.with_env_variable("DRONE_HOST", drone_host)
.with_env_variable("DRONE_USER", drone_user)
.with_secret_variable("DRONE_TOKEN", drone_token_secret)
.with_exec(vec![
"drone-templater",
"upload",
"--template",
&self.template.display(),
]);
Ok(())
}
}
}