diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index df722a4..7b3e431 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,13 +32,14 @@ jobs: git remote add upstream https://github.com/NianBroken/ZFCheckScores.git git fetch upstream main - - name: Backup local .txt files # 创建一个备份目录,并将当前目录中的所有.txt文件复制到备份目录 + # Backup local .txt files + - name: Backup local .txt files run: | mkdir backup - if [ -e *.txt ]; then + if find . -maxdepth 1 -name "*.txt" -print -quit | grep -q .; then cp *.txt backup/ else - echo "No txt file" + echo "No .txt files to backup" fi - name: Force push changes from upstream to current main branch # 将上游main分支的更改强制推送到当前main分支 @@ -47,16 +48,17 @@ jobs: git reset --hard upstream/main git push origin main --force - - name: Restore local .txt files and delete backup # 从备份目录将.txt文件还原到当前目录,然后删除备份目录 + # Restore local .txt files and delete backup + - name: Restore local .txt files and delete backup run: | - if [ -e backup/*.txt ]; then + if find backup -maxdepth 1 -name "*.txt" -print -quit | grep -q .; then cp backup/*.txt . rm -rf backup git checkout main git reset --hard upstream/main git push origin main --force else - echo "No txt file" + echo "No .txt files to restore" fi - name: Run main.py # 运行主程序main.py