Posodobitev workflow skripte za pravilno uporabo SSH ključa iz secrets
Deploy to Test Server / deploy (push) Failing after 4s Details

This commit is contained in:
Mark Poljanšek 2025-06-22 13:40:33 +02:00
parent 14cddf9a0c
commit 58752d1e42
1 changed files with 39 additions and 3 deletions

View File

@ -11,17 +11,53 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set SSH key permissions
shell: bash
run: |
# Izpis trenutne delovne mape in seznama datotek
pwd
ls -la
ls -la .gitea/runner/ || echo "Mapa runner ne obstaja"
# Poskusimo najti SSH ključ
find . -name "id_rsa_gitea*" -type f
# Uporabimo SSH ključ v bazi repozitorija
if [ -f ".gitea/runner/id_rsa_gitea" ]; then
chmod 600 .gitea/runner/id_rsa_gitea
echo "SSH ključ najden in nastavljen"
else
echo "SSH ključ ni bil najden na pričakovani lokaciji!"
# Ustvarimo SSH ključ iz kodiranega besedila
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa_gitea
chmod 600 ~/.ssh/id_rsa_gitea
echo "SSH ključ ustvarjen iz skrivnosti"
fi
- name: Deploy to test server
shell: bash
run: |
# Najprej preverimo SSH povezavo
if [ -f ".gitea/runner/id_rsa_gitea" ]; then
SSH_KEY=".gitea/runner/id_rsa_gitea"
else
SSH_KEY="~/.ssh/id_rsa_gitea"
fi
echo "Uporabljam SSH ključ: $SSH_KEY"
# Testiranje SSH povezave
ssh -p 5050 -i "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "echo 'SSH povezava uspešna'"
# Izbrišemo obstoječo vsebino v mapi vtičnika
ssh -p 5050 -i $GITHUB_WORKSPACE/.gitea/runner/id_rsa_gitea -o StrictHostKeyChecking=no forexana@152.89.234.215 "rm -rf test.forexanalysis.com/wp-content/plugins/custom_wheel\ 2/*"
ssh -p 5050 -i "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "rm -rf test.forexanalysis.com/wp-content/plugins/custom_wheel\ 2/*"
# Naredimo direktno kopiranje z rsync
rsync -avz -e "ssh -p 5050 -i $GITHUB_WORKSPACE/.gitea/runner/id_rsa_gitea -o StrictHostKeyChecking=no" --exclude=".git" --exclude=".gitea" --exclude="id_rsa_gitea*" ./ forexana@152.89.234.215:test.forexanalysis.com/wp-content/plugins/custom_wheel\ 2/
rsync -avz -e "ssh -p 5050 -i $SSH_KEY -o StrictHostKeyChecking=no" --exclude=".git" --exclude=".gitea" --exclude="id_rsa_gitea*" ./ forexana@152.89.234.215:test.forexanalysis.com/wp-content/plugins/custom_wheel\ 2/
# Nastavimo pravilna dovoljenja
ssh -p 5050 -i $GITHUB_WORKSPACE/.gitea/runner/id_rsa_gitea -o StrictHostKeyChecking=no forexana@152.89.234.215 "chmod -R 755 test.forexanalysis.com/wp-content/plugins/custom_wheel\ 2/"
ssh -p 5050 -i "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "chmod -R 755 test.forexanalysis.com/wp-content/plugins/custom_wheel\ 2/"
echo "Deployment completed successfully!"