From 5a7740c7294b397a5a950de2ef413c3695e482ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Poljan=C5=A1ek?= Date: Thu, 21 Aug 2025 11:51:18 +0200 Subject: [PATCH] napisan workflow --- .gitea/workflows/deploy.yml | 44 ++++++++++++++++++++++++++++++++++ export_code.sh | 47 ++++++++++++++++++++++++++++++------- 2 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..acd049e --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,44 @@ +name: Deploy to Production on Develop Push + +on: + push: + branches: + - develop # Sproži se samo ob pushu na 'develop' vejo + +jobs: + deploy: + runs-on: ubuntu-latest # Uporabi standardni Linux runner + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + # Ta korak prenese kodo iz vašega repozitorija v delovno okolje runnerja + + - name: Check and Install rsync + run: | + if command -v rsync &> /dev/null; then + echo "rsync is already installed." + else + echo "rsync not found. Installing..." + sudo apt-get update && sudo apt-get install -y rsync + fi + # Preveri, če je rsync na voljo. Če ni, ga namesti. + + - name: Deploy to Server via rsync + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + # Naloži zasebni SSH ključ iz Gitea skrivnosti + run: | + # Zaženemo ssh-agent in mu dodamo zasebni ključ + eval $(ssh-agent -s) + echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + + # Izvedemo rsync ukaz za sinhronizacijo + # -a: arhivski način (ohrani pravice, lastnika, itd.) + # -v: izpisuje podrobnosti (verbose) + # -z: stisne podatke med prenosom + # --delete: izbriše datoteke na cilju, ki ne obstajajo več v izvoru + # -e: določi ukaz za povezavo (ssh z vašim portom) + rsync -avz --delete -e "ssh -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no" \ + ./ \ + ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.TARGET_DIR }} \ No newline at end of file diff --git a/export_code.sh b/export_code.sh index a0428ad..4917d54 100755 --- a/export_code.sh +++ b/export_code.sh @@ -1,26 +1,57 @@ #!/bin/bash -# Set the output file +# Nastavitev imena izhodne datoteke OUTPUT_FILE="code_export.txt" -# Remove the output file if it exists +# Odstrani izhodno datoteko, če že obstaja, da začnemo s čisto datoteko if [ -f "$OUTPUT_FILE" ]; then rm "$OUTPUT_FILE" fi -# Find all files except hidden files and directories -find . -type f -not -path "*/\.*" -not -path "*node_modules*" -not -path "*vendor*" | sort | while read -r file; do - # Skip the output file itself and this script +# Poišči vse datoteke, razen skritih datotek in določenih map (npr. node_modules). +# Dodane so izjeme za slike, videoposnetke, PDF-je, arhive in druge binarne datoteke +# neposredno v ukaz 'find' za boljšo zmogljivost. +find . -type f \ + -not -path "*/\.*" \ + -not -path "*node_modules*" \ + -not -path "*vendor*" \ + -not -path "*dist*" \ + -not -path "*build*" \ + -not -name "*.jpg" -not -name "*.jpeg" \ + -not -name "*.png" -not -name "*.gif" \ + -not -name "*.bmp" -not -name "*.tiff" \ + -not -name "*.svg" -not -name "*.ico" \ + -not -name "*.webp" \ + -not -name "*.mp4" -not -name "*.mov" \ + -not -name "*.avi" -not -name "*.mkv" \ + -not -name "*.webm" \ + -not -name "*.mp3" -not -name "*.wav" \ + -not -name "*.ogg" -not -name "*.flac" \ + -not -name "*.pdf" \ + -not -name "*.zip" \ + -not -name "*.tar" \ + -not -name "*.gz" \ + -not -name "*.bz2" \ + -not -name "*.rar" \ + -not -name "*.7z" \ + -not -name "*.doc" -not -name "*.docx" \ + -not -name "*.xls" -not -name "*.xlsx" \ + -not -name "*.ppt" -not -name "*.pptx" \ + -not -name "*.eot" -not -name "*.ttf" \ + -not -name "*.woff" -not -name "*.woff2" \ + | sort | while read -r file; do + + # Preskoči samo izhodno datoteko in to skripto if [[ "$file" == "./$OUTPUT_FILE" || "$file" == "./export_code.sh" ]]; then continue fi - # Skip binary files and the output file itself + # Dodatna varnostna preverba: preskoči binarne datoteke, ki jih 'find' morda ni ujel if file "$file" | grep -q "binary"; then continue fi - # Add the filename and content to the output file + # Dodaj ime datoteke in njeno vsebino v izhodno datoteko echo "\"$file\" : " >> "$OUTPUT_FILE" echo "\"\"\"" >> "$OUTPUT_FILE" cat "$file" >> "$OUTPUT_FILE" @@ -29,4 +60,4 @@ find . -type f -not -path "*/\.*" -not -path "*node_modules*" -not -path "*vendo echo "" >> "$OUTPUT_FILE" done -echo "Code export completed. Output saved to $OUTPUT_FILE" \ No newline at end of file +echo "Izvoz kode končan. Vsebina je shranjena v datoteko $OUTPUT_FILE" \ No newline at end of file