Dodana workflow datoteka za avtomatsko posodabljanje produkcijske verzije vtičnika ob push na master vejo
Deploy to Test Server / deploy (push) Failing after 9s Details
Deploy to Production Server / deploy (push) Failing after 9s Details

This commit is contained in:
Mark Poljanšek 2025-06-22 13:46:59 +02:00
parent 2420fe6ed6
commit 175f79e303
1 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,77 @@
name: Deploy to Production Server
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
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
# Uporabimo SSH ključ iz skrivnosti
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa_gitea
chmod 600 ~/.ssh/id_rsa_gitea
echo "SSH ključ ustvarjen iz skrivnosti"
- name: Install rsync
shell: bash
run: |
# Preverimo, ali lahko namestimo rsync
echo "Preverjanje možnosti namestitve rsync..."
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
# Preverimo, ali je rsync nameščen
if command -v rsync &> /dev/null; then
echo "rsync je nameščen, verzija:"
rsync --version | head -n 1
else
echo "rsync ni nameščen, uporabili bomo tar"
fi
- name: Deploy to production server
shell: bash
run: |
SSH_KEY="~/.ssh/id_rsa_gitea"
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 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/*"
# 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/"
echo "Production deployment completed successfully!"