4NK_template/scripts/scripts/setup-ssh-ci.sh
Your Name 03fc255fdc
Some checks failed
CI - 4NK Node / Code Quality (push) Failing after 46s
CI - 4NK Node / Unit Tests (push) Failing after 29s
CI - 4NK Node / Integration Tests (push) Failing after 10s
CI - 4NK Node / Docker Build & Test (push) Failing after 8s
CI - 4NK Node / Documentation Tests (push) Failing after 4s
CI - 4NK Node / Security Tests (push) Failing after 27s
CI - 4NK Node / Release Guard (push) Has been skipped
CI - 4NK Node / Performance Tests (push) Failing after 27s
CI - 4NK Node / Notify (push) Failing after 1s
chore(template): update cursor rules, gitea templates, guards, ignores
2025-08-27 11:19:19 +02:00

55 lines
1.7 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
# Script de configuration SSH pour CI/CD (template Linux)
# Utilise automatiquement la clé SSH pour les opérations Git
GITEA_HOST="${GITEA_HOST:-git.4nkweb.com}"
echo "🔑 Configuration automatique de la clé SSH pour CI/CD..."
if [ -n "${CI:-}" ]; then
echo "✅ Environnement CI détecté"
if [ -n "${SSH_PRIVATE_KEY:-}" ]; then
echo "🔐 Configuration de la clé SSH privée..."
mkdir -p ~/.ssh && chmod 700 ~/.ssh
printf "%s" "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
if [ -n "${SSH_PUBLIC_KEY:-}" ]; then
printf "%s" "$SSH_PUBLIC_KEY" > ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/id_rsa.pub
fi
cat > ~/.ssh/config << EOF
Host ${GITEA_HOST}
HostName ${GITEA_HOST}
User git
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOF
chmod 600 ~/.ssh/config
echo "🧪 Test SSH vers ${GITEA_HOST}..."
ssh -T git@"${GITEA_HOST}" 2>&1 || true
git config --global url."git@${GITEA_HOST}:".insteadOf "https://${GITEA_HOST}/"
echo "✅ Configuration SSH terminée"
else
echo "⚠️ SSH_PRIVATE_KEY non défini, bascule HTTPS"
fi
else
echo " Environnement local détecté"
if [ -f ~/.ssh/id_rsa ] || [ -f ~/.ssh/id_ed25519 ]; then
echo "🔑 Clé SSH locale trouvée"
git config --global url."git@${GITEA_HOST}:".insteadOf "https://${GITEA_HOST}/"
echo "✅ Configuration SSH locale terminée"
else
echo "⚠️ Aucune clé SSH trouvée; configuration manuelle requise"
fi
fi
echo "🎯 Configuration SSH CI/CD terminée"