add
This commit is contained in:
@@ -2,7 +2,7 @@ name: CheckScores
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "*/30 * * * *" # 每30分钟执行一次123
|
||||
- cron: "*/30 * * * *" # 每30分钟执行一次
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force_push_message:
|
||||
@@ -41,14 +41,19 @@ jobs:
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "GitHub Actions"
|
||||
|
||||
# 拉取上游 main 分支最新代码并强制覆盖当前分支的 .github/workflows/main.yml 文件
|
||||
- name: Fetch and override upstream workflows
|
||||
# 添加上游仓库作为远程仓库,并获取上游仓库的main分支的最新更改
|
||||
- name: Fetch upstream changes
|
||||
run: |
|
||||
git remote add upstream https://github.com/NianBroken/ZFCheckScores.git
|
||||
git fetch upstream main
|
||||
git checkout upstream/main .github/workflows/main.yml
|
||||
git add .github/workflows/main.yml
|
||||
git commit -m "Override main.yml from upstream"
|
||||
git push origin main
|
||||
|
||||
# 检查上游分支的 .github/workflows/main.yml 文件是否有更改
|
||||
git diff --exit-code upstream/main -- .github/workflows/main.yml || {
|
||||
echo "Upstream main branch's .github/workflows/main.yml file has changed. Force pushing changes."
|
||||
git checkout upstream/main -- .github/workflows/main.yml
|
||||
git add .github/workflows/main.yml
|
||||
git commit -m "Update .github/workflows/main.yml from upstream"
|
||||
}
|
||||
|
||||
# 创建一个备份目录,并将当前目录中的所有.txt文件复制到备份目录
|
||||
- name: Backup local .txt files
|
||||
@@ -56,6 +61,19 @@ jobs:
|
||||
mkdir -p backup
|
||||
cp -r *.txt backup/ || echo "No .txt files to backup"
|
||||
|
||||
# 将上游main分支的更改强制推送到当前main分支
|
||||
- name: Force push changes from upstream to current main branch
|
||||
run: |
|
||||
git checkout main
|
||||
git reset --hard upstream/main
|
||||
git push origin main --force
|
||||
|
||||
# 从备份目录将.txt文件还原到当前目录,然后删除备份目录
|
||||
- name: Restore local .txt files and delete backup
|
||||
run: |
|
||||
cp -r backup/*.txt . || echo "No .txt files to restore"
|
||||
rm -rf backup
|
||||
|
||||
# 运行主程序main.py
|
||||
- name: Run main.py
|
||||
env:
|
||||
|
||||
Reference in New Issue
Block a user