Compare commits
No commits in common. "92f14f64620fe1a84deef6292aa7e6cc36a95eda" and "e42248b3af3ea0cdf6e8979cab808719c9389f0c" have entirely different histories.
92f14f6462
...
e42248b3af
|
|
@ -1,45 +1,47 @@
|
||||||
name: Deploy to Development and Production
|
name: Deploy to Staging and Production
|
||||||
|
|
||||||
on:
|
on: [push]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- develop
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# 1. Korak: Prevzem kode iz repozitorija
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup SSH
|
# 2. Korak: Namestitev SSH ključa (POENOSTAVLJENO IN POPRAVLJENO)
|
||||||
run: |
|
# Akcija bo samodejno uporabila ssh-keyscan za dodajanje prstnega odtisa strežnika.
|
||||||
mkdir -p ~/.ssh
|
# Odvečen korak "Adding Known Hosts" je odstranjen.
|
||||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
- name: Install SSH Key
|
||||||
chmod 600 ~/.ssh/id_rsa
|
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
|
- name: Deploy to Development Server
|
||||||
if: gitea.ref_name == 'develop'
|
if: gitea.ref_name == 'develop'
|
||||||
run: |
|
run: |
|
||||||
echo "🚀 Deploying to Development..."
|
echo "🚀 Deploying branch 'develop' to Development environment..."
|
||||||
rsync -avz --delete \
|
rsync -avz --delete \
|
||||||
--exclude=".git/" \
|
-e "ssh -p 22" \
|
||||||
--exclude=".gitea/" \
|
--exclude '.gitea/' \
|
||||||
--exclude=".gitignore" \
|
--exclude '.git/' \
|
||||||
-e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" \
|
./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_DIR }}
|
||||||
./ \
|
echo "✅ Deployment to Development successful!"
|
||||||
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_DIR }}
|
|
||||||
|
|
||||||
|
# 4. Korak: Razmestitev na PRODUKCIJSKI (master) strežnik
|
||||||
|
# Ta korak se izvede SAMO, če je ime veje 'master'.
|
||||||
- name: Deploy to Production Server
|
- name: Deploy to Production Server
|
||||||
if: gitea.ref_name == 'master'
|
if: gitea.ref_name == 'master'
|
||||||
run: |
|
run: |
|
||||||
echo "🚀 Deploying to Production..."
|
echo "🚀 Deploying branch 'master' to Production environment..."
|
||||||
rsync -avz --delete \
|
rsync -avz --delete \
|
||||||
--exclude=".git/" \
|
-e "ssh -p 22" \
|
||||||
--exclude=".gitea/" \
|
--exclude '.gitea/' \
|
||||||
--exclude=".gitignore" \
|
--exclude '.git/' \
|
||||||
-e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no" \
|
./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_MASTER_DIR }}
|
||||||
./ \
|
echo "✅ Deployment to Production successful!"
|
||||||
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_MASTER_DIR }}
|
|
||||||
Loading…
Reference in New Issue