Some checks failed
Deploy Incremental Updates to NEUxiaozhan / deploy (push) Failing after 0s
46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
name: Deploy Incremental Updates to NEUxiaozhan
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Prepare workspace
|
|
shell: bash
|
|
run: |
|
|
WORKSPACE="/tmp/gitea_workflow_$(date +%s)"
|
|
LOCAL_REPO="/opt/gitea/data/gitea-repositories/ember/front.git"
|
|
|
|
# 清理旧目录
|
|
if [ -d "$WORKSPACE" ]; then
|
|
rm -rf "$WORKSPACE"
|
|
fi
|
|
|
|
mkdir -p "$WORKSPACE"
|
|
git clone --bare "$LOCAL_REPO" "$WORKSPACE/repo"
|
|
echo "WORKSPACE=$WORKSPACE" >> $GITHUB_ENV
|
|
|
|
- name: Analyze changes
|
|
shell: bash
|
|
run: |
|
|
cd "$WORKSPACE/repo"
|
|
if [ $(git rev-list --count HEAD) -gt 1 ]; then
|
|
git diff --name-only HEAD^ HEAD > "$WORKSPACE/changed_files.txt"
|
|
else
|
|
git ls-tree -r HEAD --name-only > "$WORKSPACE/changed_files.txt"
|
|
fi
|
|
|
|
- name: Sync changes
|
|
shell: bash
|
|
run: |
|
|
# 同步文件
|
|
rsync -av --chmod=D2775,F664 \
|
|
--files-from="$WORKSPACE/changed_files.txt" \
|
|
"$WORKSPACE/repo/" \
|
|
/www/wwwroot/front/public/
|
|
|
|
# 确保清理工作区
|
|
rm -rf "$WORKSPACE" |