From 58752d1e429fa4fefe7c7ea988443a8b1bae1c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Poljan=C5=A1ek?= Date: Sun, 22 Jun 2025 13:40:33 +0200 Subject: [PATCH] =?UTF-8?q?Posodobitev=20workflow=20skripte=20za=20praviln?= =?UTF-8?q?o=20uporabo=20SSH=20klju=C4=8Da=20iz=20secrets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/deploy-to-test.yml | 42 ++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy-to-test.yml b/.gitea/workflows/deploy-to-test.yml index 374c087..7a1ea30 100644 --- a/.gitea/workflows/deploy-to-test.yml +++ b/.gitea/workflows/deploy-to-test.yml @@ -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!" \ No newline at end of file