add
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
name: CheckScores
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "*/30 * * * *" # 每30分钟执行一次
|
||||
workflow_dispatch: # 允许手动触发workflow
|
||||
|
||||
jobs:
|
||||
CheckScores:
|
||||
runs-on: ubuntu-latest # 在最新版的Ubuntu系统上运行
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository # 使用GitHub Actions提供的动作来检出代码库
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Python # 配置Python环境
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.x # 使用Python 3.x版本
|
||||
|
||||
- name: Install dependencies # 使用pip安装项目的依赖项
|
||||
run: |
|
||||
pip install requests rsa pyquery
|
||||
|
||||
- name: Configure Git # 配置Git用户信息
|
||||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "GitHub Actions"
|
||||
|
||||
- name: Fetch upstream changes # 添加上游仓库作为远程仓库,并获取上游仓库的main分支的最新更改
|
||||
run: |
|
||||
git remote add upstream https://github.com/NianBroken/ZFCheckScores.git
|
||||
git fetch upstream main
|
||||
|
||||
- name: Backup local .txt files # 创建一个备份目录,并将当前目录中的所有.txt文件复制到备份目录
|
||||
run: |
|
||||
mkdir backup
|
||||
cp *.txt backup/
|
||||
|
||||
- name: Force push changes from upstream to current main branch # 将上游main分支的更改强制推送到当前main分支
|
||||
run: |
|
||||
git checkout main
|
||||
git reset --hard upstream/main
|
||||
git push origin main --force
|
||||
|
||||
- name: Restore local .txt files and delete backup # 从备份目录将.txt文件还原到当前目录,然后删除备份目录
|
||||
run: |
|
||||
cp backup/*.txt .
|
||||
rm -rf backup
|
||||
|
||||
- name: Run main.py # 运行主程序main.py
|
||||
run: python main.py
|
||||
env:
|
||||
URL: ${{ secrets.URL }}
|
||||
USERNAME: ${{ secrets.USERNAME }}
|
||||
PASSWORD: ${{ secrets.PASSWORD }}
|
||||
TOKEN: ${{ secrets.TOKEN }}
|
||||
|
||||
- name: Add changes # 将当前目录中的所有更改添加到Git的暂存区
|
||||
run: |
|
||||
git add .
|
||||
|
||||
- name: Commit changes # 提交更改到Git仓库
|
||||
run: |
|
||||
git commit -m "Update from GitHub Actions" || true # 如果没有更改,则允许提交失败,但不中断workflow
|
||||
|
||||
- name: Force push changes to main branch # 将更改强制推送到main分支
|
||||
run: |
|
||||
git push origin main --force
|
||||
Reference in New Issue
Block a user