From 18da7255677fbee6c06a43b5c5f8dcb662b86f16 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 16 Apr 2026 13:11:23 +0200 Subject: [PATCH] Refactor deployment scripts to use git fetch and reset for pulling latest changes. Update deploy-production.sh and deploy-test.sh to ensure a clean state before deployment. Modify code-analysis.yml to reflect these changes in deployment commands. --- .gitea/workflows/code-analysis.yml | 4 ++-- deploy-production.sh | 4 +++- deploy-test.sh | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/code-analysis.yml b/.gitea/workflows/code-analysis.yml index 5e69f94..4d55d2e 100644 --- a/.gitea/workflows/code-analysis.yml +++ b/.gitea/workflows/code-analysis.yml @@ -118,7 +118,7 @@ jobs: -o BatchMode=yes \ -p "${{ vars.PROD_PORT }}" \ "${{ vars.PROD_USER }}@${{ vars.PROD_HOST }}" \ - "bash -lc 'cd /var/www/harheimertc && ./deploy-production.sh'" + "bash -lc 'cd /var/www/harheimertc && git fetch origin main && git checkout -B main origin/main && git reset --hard origin/main && ./deploy-production.sh'" deploy-test: runs-on: ubuntu-latest @@ -149,4 +149,4 @@ jobs: -o BatchMode=yes \ -p "${{ vars.PROD_PORT }}" \ "${{ vars.PROD_USER }}@${{ vars.PROD_HOST }}" \ - "bash -lc 'cd /var/www/harheimertc.test && ./deploy-test.sh'" + "bash -lc 'cd /var/www/harheimertc.test && git fetch origin dev && git checkout -B dev origin/dev && git reset --hard origin/dev && ./deploy-test.sh'" diff --git a/deploy-production.sh b/deploy-production.sh index a85f393..0047a64 100755 --- a/deploy-production.sh +++ b/deploy-production.sh @@ -208,7 +208,9 @@ git clean -fd \ # Pull latest changes echo " Pulling latest changes..." -if ! git pull --ff-only; then +git fetch origin main +git checkout -B main origin/main +if ! git reset --hard origin/main; then echo "ERROR: git pull fehlgeschlagen." echo "" echo "Häufige Ursache: SSH-Key für den aktuellen User fehlt." diff --git a/deploy-test.sh b/deploy-test.sh index fac56aa..cd3be43 100755 --- a/deploy-test.sh +++ b/deploy-test.sh @@ -215,8 +215,8 @@ git clean -fd \ # Pull latest changes echo " Pulling latest changes..." git fetch origin dev -git checkout dev -if ! git pull --ff-only origin dev; then +git checkout -B dev origin/dev +if ! git reset --hard origin/dev; then echo "ERROR: git pull fehlgeschlagen." echo "" echo "Häufige Ursache: SSH-Key für den aktuellen User fehlt."