Dodajanje exit 0 za preprečevanje napak pri namestitvi rsync
Deploy to Production Server / deploy (push) Failing after 11s Details

This commit is contained in:
Mark Poljanšek 2025-06-22 18:50:20 +02:00
parent f19302be25
commit 3aef9b2e9a
2 changed files with 82 additions and 6 deletions

View File

@ -25,6 +25,38 @@ jobs:
chmod 600 ~/.ssh/id_rsa_gitea
echo "SSH ključ ustvarjen iz skrivnosti"
- name: Install rsync
shell: bash
run: |
# Najprej preverimo, ali je rsync že nameščen
if command -v rsync &> /dev/null; then
echo "rsync je že nameščen, verzija:"
rsync --version | head -n 1
else
# Če rsync ni nameščen, ga poskušamo namestiti
echo "rsync ni nameščen, poskušam namestiti..."
if command -v apt-get &> /dev/null; then
echo "Poskušam namestiti rsync z apt-get..."
sudo apt-get update && sudo apt-get install -y rsync || echo "Ni mogoče namestiti rsync z apt-get"
elif command -v yum &> /dev/null; then
echo "Poskušam namestiti rsync z yum..."
sudo yum install -y rsync || echo "Ni mogoče namestiti rsync z yum"
else
echo "Ni mogoče namestiti rsync - manjka paketni upravljalnik"
fi
# Ponovno preverimo, ali je namestitev uspela
if command -v rsync &> /dev/null; then
echo "rsync je uspešno nameščen, verzija:"
rsync --version | head -n 1
else
echo "rsync ni uspešno nameščen, uporabili bomo tar"
fi
fi
# Vedno vrnemo uspešno kodo za izhod, da korak ne bo označen kot neuspešen
exit 0
- name: Deploy to production server
shell: bash
run: |
@ -38,9 +70,15 @@ jobs:
# Izbrišemo obstoječo vsebino v mapi vtičnika v produkcijskem okolju
ssh -p 5050 -i "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "rm -rf public_html/wp-content/plugins/custom_wheel\ 2/*"
# Prenašanje datotek z rsync
echo "Prenašanje datotek z rsync..."
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:public_html/wp-content/plugins/custom_wheel\ 2/
# Poskusimo najprej z rsync, če je nameščen
if command -v rsync &> /dev/null; then
echo "Prenašanje datotek z rsync..."
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:public_html/wp-content/plugins/custom_wheel\ 2/
else
# Alternativna metoda prenosa z uporabo tar preko SSH
echo "Prenašanje datotek s tar preko SSH..."
tar czf - --exclude=".git" --exclude=".gitea" --exclude="id_rsa_gitea*" ./ | ssh -p 5050 -i "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "tar xzf - -C public_html/wp-content/plugins/custom_wheel\ 2/"
fi
# Nastavimo pravilna dovoljenja
ssh -p 5050 -i "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "chmod -R 755 public_html/wp-content/plugins/custom_wheel\ 2/"

View File

@ -36,6 +36,38 @@ jobs:
echo "SSH ključ ustvarjen iz skrivnosti"
fi
- name: Install rsync
shell: bash
run: |
# Najprej preverimo, ali je rsync že nameščen
if command -v rsync &> /dev/null; then
echo "rsync je že nameščen, verzija:"
rsync --version | head -n 1
else
# Če rsync ni nameščen, ga poskušamo namestiti
echo "rsync ni nameščen, poskušam namestiti..."
if command -v apt-get &> /dev/null; then
echo "Poskušam namestiti rsync z apt-get..."
sudo apt-get update && sudo apt-get install -y rsync || echo "Ni mogoče namestiti rsync z apt-get"
elif command -v yum &> /dev/null; then
echo "Poskušam namestiti rsync z yum..."
sudo yum install -y rsync || echo "Ni mogoče namestiti rsync z yum"
else
echo "Ni mogoče namestiti rsync - manjka paketni upravljalnik"
fi
# Ponovno preverimo, ali je namestitev uspela
if command -v rsync &> /dev/null; then
echo "rsync je uspešno nameščen, verzija:"
rsync --version | head -n 1
else
echo "rsync ni uspešno nameščen, uporabili bomo tar"
fi
fi
# Vedno vrnemo uspešno kodo za izhod, da korak ne bo označen kot neuspešen
exit 0
- name: Deploy to test server
shell: bash
run: |
@ -54,9 +86,15 @@ jobs:
# Izbrišemo obstoječo vsebino v mapi vtičnika
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/*"
# Prenašanje datotek z rsync
echo "Prenašanje datotek z rsync..."
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/
# Poskusimo najprej z rsync, če je nameščen
if command -v rsync &> /dev/null; then
echo "Prenašanje datotek z rsync..."
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/
else
# Alternativna metoda prenosa z uporabo tar preko SSH
echo "Prenašanje datotek s tar preko SSH..."
tar czf - --exclude=".git" --exclude=".gitea" --exclude="id_rsa_gitea*" ./ | ssh -p 5050 -i "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "tar xzf - -C test.forexanalysis.com/wp-content/plugins/custom_wheel\ 2/"
fi
# Nastavimo pravilna dovoljenja
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/"