feat: use notification service
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:
parent
a1985d38d5
commit
cf7f6d45be
@ -1,5 +1,6 @@
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use cuddle_ci::cuddle_file::CuddleFile;
|
||||
@ -37,7 +38,7 @@ async fn main() -> eyre::Result<()> {
|
||||
.to_owned();
|
||||
|
||||
let render = &RustServiceRender {
|
||||
service: cuddle_file.vars.service,
|
||||
service: cuddle_file.vars.service.clone(),
|
||||
//registry: "http://127.0.0.1:7900".into(),
|
||||
//registry: "http://10.0.11.19:7900".into(),
|
||||
registry: "https://releaser.i.kjuulh.io:443".into(),
|
||||
@ -57,7 +58,69 @@ async fn main() -> eyre::Result<()> {
|
||||
ci.with_main(&CuddlePlease::new(client.clone()));
|
||||
}
|
||||
|
||||
ci.execute(std::env::args()).await?;
|
||||
let name = cuddle_file.vars.service.clone();
|
||||
let system_time = SystemTime::now().duration_since(UNIX_EPOCH)?;
|
||||
let build_notifications = client
|
||||
.pipeline("build-notification")
|
||||
.container()
|
||||
.from("docker.io/kasperhermansen/build-notifications:main-1731768496")
|
||||
.with_env_variable("TIME", system_time.as_secs().to_string())
|
||||
.with_env_variable(
|
||||
"SERVICE_HOST",
|
||||
"https://build-notifications.prod.internal.kjuulh.app",
|
||||
)
|
||||
.with_env_variable(
|
||||
"SERVICE_GRPC_HOST",
|
||||
"https://grpc.build-notifications.prod.internal.kjuulh.app",
|
||||
);
|
||||
|
||||
if let Err(e) = build_notifications
|
||||
.with_exec(vec![
|
||||
"build-notifications",
|
||||
"build-started",
|
||||
"--project-name",
|
||||
&name,
|
||||
])
|
||||
.sync()
|
||||
.await
|
||||
{
|
||||
tracing::warn!("failed to send start notification: {}", e.to_string())
|
||||
}
|
||||
|
||||
match ci.execute(std::env::args()).await {
|
||||
Ok(()) => {
|
||||
if let Err(e) = build_notifications
|
||||
.with_exec(vec![
|
||||
"build-notifications",
|
||||
"build-success",
|
||||
"--project-name",
|
||||
&name,
|
||||
])
|
||||
.sync()
|
||||
.await
|
||||
{
|
||||
tracing::warn!("failed to send success notification: {}", e.to_string())
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
if let Err(e) = build_notifications
|
||||
.with_exec(vec![
|
||||
"build-notifications",
|
||||
"build-failure",
|
||||
"--project-name",
|
||||
&name,
|
||||
"--error",
|
||||
&e.to_string(),
|
||||
])
|
||||
.sync()
|
||||
.await
|
||||
{
|
||||
tracing::warn!("failed to send failure notification: {}", e.to_string())
|
||||
}
|
||||
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user