From 1b4adde2bb6321086ca0b92ee498b80d659c8818 Mon Sep 17 00:00:00 2001 From: edsea Date: Wed, 8 Oct 2025 16:10:37 +0200 Subject: [PATCH] Fix htaccess for NPM --- .gitea/workflows/rollback.yml | 47 +++++++++++++++++++++++++++++++++++ .htaccess | 2 -- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/rollback.yml diff --git a/.gitea/workflows/rollback.yml b/.gitea/workflows/rollback.yml new file mode 100644 index 0000000..202f3af --- /dev/null +++ b/.gitea/workflows/rollback.yml @@ -0,0 +1,47 @@ +# manual rollback +on: + workflow_dispatch: + inputs: + steps: + description: "How many releases to roll back (1 = previous)" + default: "1" + +jobs: + rollback: + runs-on: [ mainhost ] + env: + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_USER: ${{ secrets.SSH_USER }} + SSH_KEY_PATH: /home/gitea-runner/.ssh/id_ed25519 + SSH_OPTS: >- + -F /dev/null -o IdentitiesOnly=yes -o IdentityAgent=none + -o PreferredAuthentications=publickey -o PubkeyAuthentication=yes + -o PasswordAuthentication=no -o NumberOfPasswordPrompts=0 -o BatchMode=yes + -o ServerAliveInterval=15 -o ServerAliveCountMax=3 -o ConnectTimeout=20 + -o StrictHostKeyChecking=no + APP_ROOT: /var/www/stellaamor + SERVICE_RELOAD: "systemctl reload apache2 || true" + + steps: + - name: Roll back symlink to an older release + run: | + set -euo pipefail + APP="${{ env.APP_ROOT }}" + RELEASES="${APP}/releases" + CUR="${APP}/current" + N="${{ github.event.inputs.steps || '1' }}" + + # pick target release (1=previous) + TARGET="$(ls -1tr "${RELEASES}" | tail -n +"$((N+1))" | tail -n 1)" + if [ -z "${TARGET}" ]; then + echo "No release found to roll back to."; exit 1 + fi + echo "Rolling back to: ${TARGET}" + + ssh $SSH_OPTS -i "$SSH_KEY_PATH" ${SSH_USER}@${SSH_HOST} " + set -euo pipefail + APP='${APP}'; RELEASES='${RELEASES}'; CUR='${CUR}'; TARGET='${TARGET}'; + [ -d \"\${RELEASES}/\${TARGET}\" ] || { echo 'Target release missing'; exit 1; } + ln -sfn \"\${RELEASES}/\${TARGET}\" \"\${CUR}\" + ${SERVICE_RELOAD} >/dev/null 2>&1 || true + " diff --git a/.htaccess b/.htaccess index 10563d5..9b0590f 100644 --- a/.htaccess +++ b/.htaccess @@ -2,8 +2,6 @@ RewriteEngine On RewriteBase / -RewriteCond %{HTTPS} off -RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Add trailing slash to URLs (except files and directories) RewriteCond %{REQUEST_FILENAME} !-f