Update
This commit is contained in:
+14
-17
@@ -47,33 +47,30 @@ jobs:
|
|||||||
git remote add upstream https://github.com/NianBroken/ZFCheckScores.git
|
git remote add upstream https://github.com/NianBroken/ZFCheckScores.git
|
||||||
git fetch upstream main
|
git fetch upstream main
|
||||||
|
|
||||||
# 定义文件后缀列表
|
# 创建一个备份目录,并将当前目录中的所有.txt文件复制到备份目录
|
||||||
- name: Define file extensions
|
- name: Backup local .txt files
|
||||||
run: |
|
|
||||||
# 可以根据需要添加其他文件后缀,以空格分隔
|
|
||||||
FILE_EXTENSIONS=".txt .txt123"
|
|
||||||
|
|
||||||
# 创建一个备份目录,并将当前目录及子目录中的所有指定后缀文件复制到备份目录,并保持路径
|
|
||||||
- name: Backup local files with specified extensions
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p backup
|
mkdir -p backup
|
||||||
for EXT in $FILE_EXTENSIONS; do
|
cp -r *.txt backup/ || echo "No .txt files to backup"
|
||||||
find . -type f -name "*$EXT" -exec cp --parents {} backup/ \; || echo "No $EXT files to backup"
|
|
||||||
done
|
|
||||||
|
|
||||||
# 将上游main分支的更改强制推送到当前main分支
|
# 将上游main分支的更改强制推送到当前main分支
|
||||||
- name: Force push changes from upstream to current main branch
|
- name: Force push changes from upstream to current main branch
|
||||||
run: |
|
run: |
|
||||||
git checkout main
|
git checkout main
|
||||||
git reset --hard upstream/main
|
git reset --hard upstream/main
|
||||||
git push origin main --force
|
git push origin main --force || (for i in {1..10}; do
|
||||||
|
echo "------" &&
|
||||||
|
echo "你需要手动同步上游分支" &&
|
||||||
|
echo "同步方法如下:" &&
|
||||||
|
echo "1. 打开你的仓库首页:https://github.com/${{ github.repository }}" &&
|
||||||
|
echo "2. 点击 Sync fork"&&
|
||||||
|
echo "3. 点击 Update branch 或 Discard xxx commits";
|
||||||
|
done; exit 1)
|
||||||
|
|
||||||
# 从备份目录将指定后缀文件还原到当前目录及子目录中,然后删除备份目录
|
# 从备份目录将.txt文件还原到当前目录,然后删除备份目录
|
||||||
- name: Restore local files with specified extensions and delete backup
|
- name: Restore local .txt files and delete backup
|
||||||
run: |
|
run: |
|
||||||
for EXT in $FILE_EXTENSIONS; do
|
cp -r backup/*.txt . || echo "No .txt files to restore"
|
||||||
find backup -type f -name "*$EXT" -exec cp --parents {} . \; || echo "No $EXT files to restore"
|
|
||||||
done
|
|
||||||
rm -rf backup
|
rm -rf backup
|
||||||
|
|
||||||
# 运行主程序main.py
|
# 运行主程序main.py
|
||||||
|
|||||||
Reference in New Issue
Block a user