From 0b9709d5c4df30034deb0394c98e9da93f56b440 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 12 Aug 2023 20:50:23 +0200 Subject: [PATCH] fix(ci): repo should be ssh Signed-off-by: kjuulh --- Cargo.lock | 4 +- crates/dagger-cuddle-please/src/lib.rs | 61 ++++++++++++++++++-------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 452e742..d055dc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,9 +86,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", diff --git a/crates/dagger-cuddle-please/src/lib.rs b/crates/dagger-cuddle-please/src/lib.rs index 61f5009..2371677 100644 --- a/crates/dagger-cuddle-please/src/lib.rs +++ b/crates/dagger-cuddle-please/src/lib.rs @@ -275,7 +275,6 @@ impl DaggerCuddlePlease { args: &CuddlePleaseSrcArgs, ) -> eyre::Result<()> { let build_image = client.container().from(&args.cuddle_image); - let res = build_image .with_secret_variable( "CUDDLE_PLEASE_TOKEN", @@ -309,6 +308,7 @@ impl DaggerCuddlePlease { contents: Some( " Host * + User git StrictHostKeyChecking no UserKnownHostsFile /dev/null ", @@ -316,26 +316,49 @@ Host * owner: Some("root"), permissions: Some(700), }, - ) - .with_exec(vec![ - "cuddle-please", - "release", + ); + + let remote_url = res + .with_exec(vec!["git", "config", "--get", "remote.origin.url"]) + .stdout() + .await?; + + let res = if remote_url.starts_with("http") { + res.with_exec(vec![ + "git", + "config", + "--global", &format!( - "--engine={}", - match &args.server { - SrcServer::Gitea { .. } => "gitea", - SrcServer::GitHub { .. } => "github", - } + "url.ssh://git@{}/.insteadOf", + remote_url + .trim_start_matches("https://") + .trim_start_matches("http://") ), - "--log-level", - match args.log_level.as_ref().unwrap_or(&LogLevel::Info) { - LogLevel::Trace => "trace", - LogLevel::Debug => "debug", - LogLevel::Info => "info", - LogLevel::Warn => "warn", - LogLevel::Error => "error", - }, - ]); + &remote_url, + ]) + } else { + res + }; + + let res = res.with_exec(vec![ + "cuddle-please", + "release", + &format!( + "--engine={}", + match &args.server { + SrcServer::Gitea { .. } => "gitea", + SrcServer::GitHub { .. } => "github", + } + ), + "--log-level", + match args.log_level.as_ref().unwrap_or(&LogLevel::Info) { + LogLevel::Trace => "trace", + LogLevel::Debug => "debug", + LogLevel::Info => "info", + LogLevel::Warn => "warn", + LogLevel::Error => "error", + }, + ]); let exit_code = res.exit_code().await?; if exit_code != 0 {