LTDV8/.gitea/workflows/delopy.yml
3944Realms 3a892d4d6b
Some checks failed
Deploy to Remote Server / deploy (push) Failing after 1m7s
初始化测试工作流脚本
2025-10-26 19:18:11 +08:00

52 lines
1.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy to Remote Server
on:
push:
branches: [ main, master ]
# 也可以手动触发
workflow_dispatch:
env:
REMOTE_HOST: "leisueretimedock.top"
REMOTE_USER: "root"
REMOTE_PATH: "/opt/filebrowser/ltd v8"
SSH_PORT: "22"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -p $SSH_PORT $REMOTE_HOST >> ~/.ssh/known_hosts
- name: Prepare remote directory
run: |
ssh -p $SSH_PORT $REMOTE_USER@$REMOTE_HOST "
mkdir -p '$REMOTE_PATH'
# 安全清理目录内容
if [ \"\$(ls -A '$REMOTE_PATH' 2>/dev/null)\" ]; then
rm -rf '$REMOTE_PATH'/*
echo 'Directory cleaned'
fi
"
- name: Transfer files with tar
run: |
# 使用tar管道传输保留文件权限和结构
tar czf - --exclude='.git' --exclude='.github' . | \
ssh -p $SSH_PORT $REMOTE_USER@$REMOTE_HOST "cd '$REMOTE_PATH' && tar xzf -"
- name: Set proper permissions
run: |
ssh -p $SSH_PORT $REMOTE_USER@$REMOTE_HOST "
chmod -R 755 '$REMOTE_PATH'
echo 'Permissions set'
"