Compare commits

..

No commits in common. "92f14f64620fe1a84deef6292aa7e6cc36a95eda" and "e42248b3af3ea0cdf6e8979cab808719c9389f0c" have entirely different histories.

1 changed files with 29 additions and 27 deletions

View File

@ -1,45 +1,47 @@
name: Deploy to Development and Production
name: Deploy to Staging and Production
on:
push:
branches:
- develop
- master
on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 1. Korak: Prevzem kode iz repozitorija
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# 2. Korak: Namestitev SSH ključa (POENOSTAVLJENO IN POPRAVLJENO)
# Akcija bo samodejno uporabila ssh-keyscan za dodajanje prstnega odtisa strežnika.
# Odvečen korak "Adding Known Hosts" je odstranjen.
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_HOST }} # Pravilen način uporabe!
# 3. Korak: Razmestitev na RAZVOJNI (development) strežnik
# Ta korak se izvede SAMO, če je ime veje 'develop'.
- name: Deploy to Development Server
if: gitea.ref_name == 'develop'
run: |
echo "🚀 Deploying to Development..."
echo "🚀 Deploying branch 'develop' to Development environment..."
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 }}
-e "ssh -p 22" \
--exclude '.gitea/' \
--exclude '.git/' \
./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_DIR }}
echo "✅ Deployment to Development successful!"
# 4. Korak: Razmestitev na PRODUKCIJSKI (master) strežnik
# Ta korak se izvede SAMO, če je ime veje 'master'.
- name: Deploy to Production Server
if: gitea.ref_name == 'master'
run: |
echo "🚀 Deploying to Production..."
echo "🚀 Deploying branch 'master' to Production environment..."
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 }}
-e "ssh -p 22" \
--exclude '.gitea/' \
--exclude '.git/' \
./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_MASTER_DIR }}
echo "✅ Deployment to Production successful!"