This commit is contained in:
NianBroken
2024-02-13 14:57:19 +08:00 Unverified
parent 78f920e64c
commit 2acbaaa4ff
+6 -11
View File
@@ -47,16 +47,11 @@ jobs:
git remote add upstream https://github.com/NianBroken/ZFCheckScores.git
git fetch upstream main
# 定义文件后缀变量
- name: Define file extensions
run: |
FILE_EXTENSIONS=".txt .jpg .png" # 你可以在这里添加更多的文件后缀,以空格分隔
# 创建一个备份目录,并将当前目录及子目录中的所有指定后缀文件复制到备份目录,并保持路径
- name: Backup local files
# 创建一个备份目录,并将当前目录及子目录中的所有.txt文件复制到备份目录,并保持路径,输出文件路径
- name: Backup local .txt files
run: |
mkdir -p backup
rsync -av --include="*/" $(echo $FILE_EXTENSIONS | sed 's/\./\\\./g' | sed 's/ / --include="*"/g' | sed 's/^/ --include="*"/') --exclude="*" ./ backup/
rsync -av --include="*/" --include="*.txt" --exclude="*" ./ backup/ | awk '{print $NF}'
# 将上游main分支的更改强制推送到当前main分支
- name: Force push changes from upstream to current main branch
@@ -72,10 +67,10 @@ jobs:
echo "3. 点击 Update branch 或 Discard xxx commits";
done; exit 1)
# 从备份目录将指定后缀文件还原到当前目录及子目录中,然后删除备份目录
- name: Restore local files and delete backup
# 从备份目录将.txt文件还原到当前目录及子目录中,然后删除备份目录,输出文件路径
- name: Restore local .txt files and delete backup
run: |
rsync -av --include="*/" $(echo $FILE_EXTENSIONS | sed 's/\./\\\./g' | sed 's/ / --include="*"/g' | sed 's/^/ --include="*"/') --exclude="*" backup/ ./
rsync -av --include="*/" --include="*.txt" --exclude="*" backup/ ./ | awk '{print $NF}'
rm -rf backup
# 运行主程序main.py