From 72bde4b6a102ba8aa7e94df06f87670fe1e3b5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A2=8E=E5=BF=B5=5FNian?= Date: Fri, 2 Feb 2024 21:22:46 +0800 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cfa3b4..4403646 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,10 +32,15 @@ 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 - cp *.txt backup/ + if [ -e *.txt ]; then + cp *.txt backup/ + else + echo "No .txt files to backup" + fi - name: Force push changes from upstream to current main branch # 将上游main分支的更改强制推送到当前main分支 run: | @@ -43,10 +48,15 @@ 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: | - cp backup/*.txt . - rm -rf backup + if [ -e backup/*.txt ]; then + cp backup/*.txt . + rm -rf backup + else + echo "No .txt files to restore" + fi - name: Run main.py # 运行主程序main.py run: python main.py