fix: add ssh keys to ~/.ssh/config

This commit is contained in:
Jozef Steinhübl 2024-07-23 18:01:18 +02:00
parent 91479c8f94
commit e0e29bfd28
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F
2 changed files with 14 additions and 8 deletions

View file

@ -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

View file

@ -13,7 +13,7 @@
"sources:\n" \
" - \"https://%s/%s/%s\"\n" \
"secrets:\n" \
" - <add>\n" \
" - <secret>\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/<secret>\" >> ~/.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);