Sprememba pipelinesov
Deploy to Development and Production / deploy (push) Failing after 14s Details

This commit is contained in:
Mark Poljanšek 2025-11-20 22:09:13 +01:00
parent 5210c9d2e6
commit 035ecdee43
3 changed files with 51 additions and 170 deletions

View File

@ -1,77 +0,0 @@
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!"

View File

@ -1,93 +0,0 @@
name: Deploy to Test Server
on:
push:
branches:
- develop
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
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: 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 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 "$SSH_KEY" -o StrictHostKeyChecking=no forexana@152.89.234.215 "rm -rf 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/"
echo "Deployment completed successfully!"

View File

@ -0,0 +1,51 @@
name: Deploy to Development and Production
# 1. EN trigger, ki se sproži ob potisku na OBE veji
on:
push:
branches:
- develop
- master
# 2. EN jobs blok
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Ta korak se vedno izvede
- name: Checkout repository
uses: actions/checkout@v4
# Ta korak se vedno izvede - priprava SSH ključa
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# 3. KORAK ZA DEVELOP: Izvede se samo, če je veja 'develop'
- name: Deploy to Development Server
if: gitea.ref_name == 'develop'
run: |
echo "🚀 Deploying to Development..."
rsync -avz --delete \
--exclude=".git/" \
--exclude=".gitea/" \
--exclude=".gitignore" \
-e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" \
./ \
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_DIR }}
# 4. KORAK ZA MASTER: Izvede se samo, če je veja 'master'
- name: Deploy to Production Server
if: gitea.ref_name == 'master'
run: |
echo "🚀 Deploying to Production..."
rsync -avz --delete \
--exclude=".git/" \
--exclude=".gitea/" \
--exclude=".gitignore" \
-e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" \
./ \
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_MASTER_DIR }}