From e0e29bfd28e6d5398ad4b20519f5016946e83e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Steinh=C3=BCbl?= Date: Tue, 23 Jul 2024 18:01:18 +0200 Subject: [PATCH] fix: add ssh keys to ~/.ssh/config --- .builds/alpine.yml | 12 ++++++++---- src/cli/command/ci.c | 10 ++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.builds/alpine.yml b/.builds/alpine.yml index 9de05c8..d269844 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -4,8 +4,8 @@ packages: sources: - "https://git.sr.ht/~hyro/gimi" secrets: - - 55691174-b52f-477c-81ea-dd32deff19b8 - - 3eaa5e52-e929-4822-842b-e817e0be7e39 + - 55691174-b52f-477c-81ea-dd32deff19b8 # github + - 3eaa5e52-e929-4822-842b-e817e0be7e39 # codeberg tasks: - sync: | cd gimi @@ -13,10 +13,14 @@ tasks: git remote add gimi-github git@github.com:xhyrom/gimi.git ssh-keyscan github.com >> ~/.ssh/known_hosts - git push -f --all --tags gimi-github + echo -e "Host github.com\nUser git\nIdentityFile ${HOME}/.ssh/55691174-b52f-477c-81ea-dd32deff19b8" >> ~/.ssh/config + git push -f --all gimi-github + git push -f --tags gimi-github git remote add gimi-codeberg git@codeberg.org:xHyroM/gimi.git ssh-keyscan codeberg.org >> ~/.ssh/known_hosts - git push -f --all --tags gimi-codeberg + echo -e "Host codeberg.org\nUser git\nIdentityFile ${HOME}/.ssh/3eaa5e52-e929-4822-842b-e817e0be7e39" >> ~/.ssh/config + git push -f --all gimi-codeberg + git push -f --tags gimi-codeberg set -x diff --git a/src/cli/command/ci.c b/src/cli/command/ci.c index 38efadc..9eb6e19 100644 --- a/src/cli/command/ci.c +++ b/src/cli/command/ci.c @@ -13,7 +13,7 @@ "sources:\n" \ " - \"https://%s/%s/%s\"\n" \ "secrets:\n" \ - " - \n" \ + " - \n" \ "tasks:\n" \ " - sync: |\n" \ " cd %s\n" \ @@ -74,15 +74,17 @@ char *generate_sourcehut(struct gimi_config *cfg, struct repository *repo = translate_ssh_to_repository(provider->ssh); - char buf[256]; + char buf[1024]; snprintf(buf, sizeof(buf), "\n" "\n git remote add gimi-%s %s " "\n ssh-keyscan %s >> ~/.ssh/known_hosts" + "\n echo -e \"Host %s\\nUser git\\nIdentityFile " + "${HOME}/.ssh/\" >> ~/.ssh/config" "\n git push -f --all gimi-%s" "\n git push -f --tags gimi-%s", - provider->name, provider->ssh, repo->domain, provider->name, - provider->name); + provider->name, provider->ssh, repo->domain, repo->domain, + provider->name, provider->name); strcat(remotes, buf);