From ef18489d75e215932f402833efb1ef6c7f3aea3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A2=8E=E5=BF=B5=5FNian?= Date: Fri, 2 Feb 2024 21:30:39 +0800 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0754c94..df722a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,14 +32,13 @@ jobs: git remote add upstream https://github.com/NianBroken/ZFCheckScores.git git fetch upstream main - # Backup local .txt files - - name: Backup local .txt files + - name: Backup local .txt files # 创建一个备份目录,并将当前目录中的所有.txt文件复制到备份目录 run: | mkdir backup - if ls *.txt &> /dev/null; then + if [ -e *.txt ]; then cp *.txt backup/ else - echo "No .txt files to backup" + echo "No txt file" fi - name: Force push changes from upstream to current main branch # 将上游main分支的更改强制推送到当前main分支 @@ -48,14 +47,16 @@ jobs: git reset --hard upstream/main git push origin main --force - # Restore local .txt files and delete backup - - name: Restore local .txt files and delete backup + - name: Restore local .txt files and delete backup # 从备份目录将.txt文件还原到当前目录,然后删除备份目录 run: | - if ls backup/*.txt &> /dev/null; then + if [ -e backup/*.txt ]; then cp backup/*.txt . rm -rf backup + git checkout main + git reset --hard upstream/main + git push origin main --force else - echo "No .txt files to restore" + echo "No txt file" fi - name: Run main.py # 运行主程序main.py