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