feat: conditionally disable deployment
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
parent
3a6f5bb6d2
commit
926199a487
@ -37,6 +37,7 @@ pub struct RustService {
|
|||||||
bin_name: String,
|
bin_name: String,
|
||||||
arch: Option<Architecture>,
|
arch: Option<Architecture>,
|
||||||
os: Option<Os>,
|
os: Option<Os>,
|
||||||
|
deployment: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<dagger_sdk::Query> for RustService {
|
impl From<dagger_sdk::Query> for RustService {
|
||||||
@ -51,6 +52,7 @@ impl From<dagger_sdk::Query> for RustService {
|
|||||||
bin_name: String::new(),
|
bin_name: String::new(),
|
||||||
arch: None,
|
arch: None,
|
||||||
os: None,
|
os: None,
|
||||||
|
deployment: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,6 +69,7 @@ impl RustService {
|
|||||||
bin_name: String::new(),
|
bin_name: String::new(),
|
||||||
arch: None,
|
arch: None,
|
||||||
os: None,
|
os: None,
|
||||||
|
deployment: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +118,12 @@ impl RustService {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_deployment(&mut self, deployment: bool) -> &mut Self {
|
||||||
|
self.deployment = deployment;
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn get_src(&self) -> PathBuf {
|
fn get_src(&self) -> PathBuf {
|
||||||
self.source
|
self.source
|
||||||
.clone()
|
.clone()
|
||||||
@ -339,50 +348,51 @@ impl MainAction for RustService {
|
|||||||
))
|
))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let update_deployments_docker_image =
|
if self.deployment {
|
||||||
"docker.io/kasperhermansen/update-deployment:1701123940";
|
let update_deployments_docker_image =
|
||||||
let dep = self
|
"docker.io/kasperhermansen/update-deployment:1701123940";
|
||||||
.client
|
let dep = self
|
||||||
.container()
|
.client
|
||||||
.from(update_deployments_docker_image);
|
.container()
|
||||||
|
.from(update_deployments_docker_image);
|
||||||
|
|
||||||
let dep = if let Some(sock) = std::env::var("SSH_AUTH_SOCK").ok() {
|
let dep = if let Ok(sock) = std::env::var("SSH_AUTH_SOCK") {
|
||||||
dep.with_unix_socket("/tmp/ssh_sock", self.client.host().unix_socket(sock))
|
dep.with_unix_socket("/tmp/ssh_sock", self.client.host().unix_socket(sock))
|
||||||
.with_env_variable("SSH_AUTH_SOCK", "/tmp/ssh_sock")
|
.with_env_variable("SSH_AUTH_SOCK", "/tmp/ssh_sock")
|
||||||
.with_exec(vec![
|
.with_exec(vec![
|
||||||
"update-deployment",
|
"update-deployment",
|
||||||
"--repo",
|
"--repo",
|
||||||
&format!(
|
&format!(
|
||||||
"git@git.front.kjuulh.io:kjuulh/{}-deployment.git",
|
"git@git.front.kjuulh.io:kjuulh/{}-deployment.git",
|
||||||
self.bin_name
|
self.bin_name
|
||||||
),
|
),
|
||||||
"--service",
|
"--service",
|
||||||
&self.bin_name,
|
&self.bin_name,
|
||||||
"--image",
|
"--image",
|
||||||
&format!("kasperhermansen/{}:main-{}", self.bin_name, timestamp),
|
&format!("kasperhermansen/{}:main-{}", self.bin_name, timestamp),
|
||||||
])
|
])
|
||||||
} else {
|
} else {
|
||||||
dep.with_env_variable("GIT_USERNAME", "kjuulh")
|
dep.with_env_variable("GIT_USERNAME", "kjuulh")
|
||||||
.with_env_variable(
|
.with_env_variable(
|
||||||
"GIT_PASSWORD",
|
"GIT_PASSWORD",
|
||||||
std::env::var("GIT_PASSWORD").expect("GIT_PASSWORD to be set"),
|
std::env::var("GIT_PASSWORD").expect("GIT_PASSWORD to be set"),
|
||||||
)
|
)
|
||||||
.with_exec(vec![
|
.with_exec(vec![
|
||||||
"update-deployment",
|
"update-deployment",
|
||||||
"--repo",
|
"--repo",
|
||||||
&format!(
|
&format!(
|
||||||
"https://git.front.kjuulh.io/kjuulh/{}-deployment.git",
|
"https://git.front.kjuulh.io/kjuulh/{}-deployment.git",
|
||||||
self.bin_name
|
self.bin_name
|
||||||
),
|
),
|
||||||
"--service",
|
"--service",
|
||||||
&self.bin_name,
|
&self.bin_name,
|
||||||
"--image",
|
"--image",
|
||||||
&format!("kasperhermansen/{}:main-{}", self.bin_name, timestamp),
|
&format!("kasperhermansen/{}:main-{}", self.bin_name, timestamp),
|
||||||
])
|
])
|
||||||
};
|
};
|
||||||
|
|
||||||
dep.sync().await?;
|
|
||||||
|
|
||||||
|
dep.sync().await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user