40 lines
1015 B
YAML
40 lines
1015 B
YAML
name: Update Contests & Commit
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '7/15 * * * *' # 每15分钟执行一次,避开整点高峰
|
|
push:
|
|
branches:
|
|
- master
|
|
workflow_dispatch: # 允许手动触发
|
|
|
|
jobs:
|
|
update:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write # 允许 Actions 推送代码
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install dependencies
|
|
run: pip install requests beautifulsoup4
|
|
|
|
- name: Fetch contests
|
|
run: python fetch_contests.py
|
|
|
|
- name: Commit and push if changed
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "[email protected]"
|
|
git add contests_all.json
|
|
git diff --staged --quiet || (
|
|
git commit -m "Update contest data"
|
|
git push
|
|
)
|