fix: use gitea API to download files one by one, bypass git pack
All checks were successful
Deploy to Server / deploy (push) Successful in 18s
All checks were successful
Deploy to Server / deploy (push) Successful in 18s
This commit is contained in:
@@ -5,24 +5,7 @@ jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
git config --global http.version HTTP/1.1
|
||||
git clone --depth=1 https://sdd:zsj981107@gitea.tangledup-ai.com/quant-speed-AI/Scoring-System.git /tmp/scoring-deploy
|
||||
|
||||
- name: Install sshpass
|
||||
run: apt-get install -y sshpass rsync
|
||||
|
||||
- name: Copy code to server
|
||||
run: |
|
||||
sshpass -p "123quant-speed" rsync -avz --delete \
|
||||
--exclude='.git' \
|
||||
--exclude='backend/.env' \
|
||||
--exclude='backend/media/' \
|
||||
-e "ssh -o StrictHostKeyChecking=no" \
|
||||
/tmp/scoring-deploy/ quant@6.6.6.66:/home/quant/data/dev/deploy/
|
||||
|
||||
- name: Deploy on server via SSH
|
||||
- name: Download and deploy code
|
||||
uses: https://gitea.com/actions/appleboy-ssh-action@v1.0.3
|
||||
with:
|
||||
host: 6.6.6.66
|
||||
@@ -31,16 +14,42 @@ jobs:
|
||||
script: |
|
||||
TARGET_DIR="/home/quant/data/dev/deploy"
|
||||
SUDO_PASSWORD="123quant-speed"
|
||||
API_BASE="https://gitea.tangledup-ai.com/api/v1"
|
||||
REPO="quant-speed-AI/Scoring-System"
|
||||
AUTH="sdd:zsj981107"
|
||||
BRANCH="main"
|
||||
|
||||
cd $TARGET_DIR
|
||||
|
||||
# 1. 停止并移除 Docker 容器
|
||||
echo "===== 停止并清理 Docker ====="
|
||||
cd $TARGET_DIR
|
||||
echo $SUDO_PASSWORD | sudo -S docker compose down
|
||||
|
||||
# 2. 创建/更新 .env 文件
|
||||
echo "===== 通过 API 下载代码 ====="
|
||||
# 获取文件树
|
||||
FILE_LIST=$(curl -sk -u "$AUTH" "$API_BASE/repos/$REPO/git/trees/$BRANCH?recursive=true" | python3 -c "
|
||||
import json,sys
|
||||
data = json.load(sys.stdin)
|
||||
for item in data.get('tree', []):
|
||||
if item['type'] == 'blob':
|
||||
print(item['path'])
|
||||
")
|
||||
|
||||
echo "共发现 $(echo "$FILE_LIST" | wc -l) 个文件"
|
||||
|
||||
# 逐个下载文件
|
||||
echo "$FILE_LIST" | while read -r filepath; do
|
||||
# 跳过不需要的文件
|
||||
case "$filepath" in
|
||||
backend/.env|backend/media/*|.git/*) continue ;;
|
||||
esac
|
||||
mkdir -p "$TARGET_DIR/$(dirname "$filepath")"
|
||||
curl -sk -u "$AUTH" -o "$TARGET_DIR/$filepath" \
|
||||
"$API_BASE/repos/$REPO/raw/$filepath?ref=$BRANCH"
|
||||
done
|
||||
|
||||
echo "代码更新完成"
|
||||
|
||||
echo "===== 配置环境变量 ====="
|
||||
cat > backend/.env <<EOF
|
||||
cat > $TARGET_DIR/backend/.env <<EOF
|
||||
# Database Configuration
|
||||
DB_NAME=scoring
|
||||
DB_USER=quant-speed
|
||||
@@ -58,8 +67,8 @@ jobs:
|
||||
DASHSCOPE_API_KEY=sk-84e9eef24a274f568d4fa15c97556c9f
|
||||
EOF
|
||||
|
||||
# 3. 重新启动 Docker 容器
|
||||
echo "===== 启动 Docker 容器 ====="
|
||||
cd $TARGET_DIR
|
||||
echo $SUDO_PASSWORD | sudo -S docker compose up -d --build
|
||||
|
||||
echo "===== 操作完成!====="
|
||||
|
||||
Reference in New Issue
Block a user