This commit is contained in:
2026-04-24 20:30:52 +08:00
commit 704bc34625
152 changed files with 45612 additions and 0 deletions

41
.github/workflows/rollback.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Switch/Rollback Version
on:
workflow_dispatch:
inputs:
version:
description: "enter the version to switch to (example: v1.0.2)"
required: true
default: ""
jobs:
switch-version:
runs-on: ubuntu-latest
steps:
- name: Execute remote SSH commands
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
REMOTE_BASE=${{ secrets.REMOTE_PATH }}
RELEASES_PATH="$REMOTE_BASE/releases"
CURRENT_PATH="$REMOTE_BASE/current"
TARGET_VERSION="${{ github.event.inputs.version }}"
echo ">>> Switching to version: $TARGET_VERSION"
# 1. Check if the target directory exists
if [ -d "$RELEASES_PATH/$TARGET_VERSION" ]; then
# 2. Modify symbolic link (use -n and -f to ensure atomic replacement of directory links)
ln -sfn "$RELEASES_PATH/$TARGET_VERSION" "$CURRENT_PATH"
echo ">>> Switching to version: $TARGET_VERSION successfully"
ls -l "$CURRENT_PATH"
else
echo ">>> Error: Version $TARGET_VERSION does not exist in $RELEASES_PATH"
echo ">>> Existing version list:"
ls -1 "$RELEASES_PATH"
exit 1
fi