feat: include pipeline
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -11,60 +11,4 @@ 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 eyre::Context;
|
||||
|
||||
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").context("DRONE_HOST is missing")?;
|
||||
let drone_user = std::env::var("DRONE_USER").context("DRONE_USER is missing")?;
|
||||
let drone_token = std::env::var("DRONE_TOKEN").context("DRONE_TOKEN is missing")?;
|
||||
|
||||
let drone_token_secret = self.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().to_string(),
|
||||
])
|
||||
.sync()
|
||||
.await
|
||||
.context("failed to upload drone templates with error")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
pub mod drone_templater;
|
||||
|
Reference in New Issue
Block a user