name: Deploy Incremental Updates to NEUxiaozhan on: push: branches: [master] jobs: deploy: runs-on: self-hosted steps: - name: Prepare workspace shell: bash run: | # 设置本地仓库路径(根据实际路径调整) LOCAL_REPO="/opt/gitea/data/gitea-repositories/ember/front.git" WORKSPACE="/tmp/gitea_workflow" # 创建临时工作区 mkdir -p $WORKSPACE cd $WORKSPACE # 克隆本地仓库(使用bare repo) git clone $LOCAL_REPO . - name: Get changed files id: changed-files shell: bash run: | cd /tmp/gitea_workflow # 处理首次提交的情况 if git rev-parse HEAD^ >/dev/null 2>&1; then git diff --name-only HEAD^ HEAD > changed_files.txt else git ls-files > changed_files.txt fi # 生成绝对路径文件列表 sed -i "s|^|$WORKSPACE/|" changed_files.txt echo "CHANGED_FILES=/tmp/gitea_workflow/changed_files.txt" >> $GITHUB_ENV - name: Sync changes shell: bash run: | # 创建目标目录 sudo mkdir -p /www/wwwroot/front/public # 带权限同步(使用sudo保留权限) sudo rsync -av --chown=www-data:www-data \ --files-from=$CHANGED_FILES \ /tmp/gitea_workflow/ \ /www/wwwroot/front/public/ # 清理临时文件 rm -rf /tmp/gitea_workflow