forked from Rockytkg/AutoMoGuDingCheckIn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
13 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,46 @@ | ||
name: "打卡" | ||
|
||
# 明确触发条件 | ||
on: | ||
workflow_dispatch: # 手动触发 | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "*/5 * * * *" | ||
# 使用 UTC 时间,UTC 时间 对应 北京时间 -8 小时 | ||
- cron: "30 0 * * *" # UTC 00:30 / 北京时间 08:30 | ||
- cron: "0 1 * * *" # UTC 01:00 / 北京时间 09:00 | ||
- cron: "30 12 * * *" # UTC 12:30 / 北京时间 20:30 | ||
- cron: "0 13 * * *" # UTC 13:00 / 北京时间 21:00 | ||
- cron: "30 0 * * *" | ||
- cron: "0 1 * * *" | ||
- cron: "30 12 * * *" | ||
- cron: "0 13 * * *" | ||
|
||
# 配置并发控制,避免任务重叠执行 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 # 添加超时限制 | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
# 设置时区为 Asia/Shanghai | ||
- name: Set timezone | ||
uses: szenius/[email protected] | ||
with: | ||
timezoneLinux: "Asia/Shanghai" | ||
|
||
# 检出代码仓库 | ||
- name: Checkout repository | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 # 优化克隆深度 | ||
fetch-depth: 1 | ||
|
||
# 设置 Python 环境 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
cache: 'pip' # 启用 pip 缓存 | ||
check-latest: true # 检查是否有更新的补丁版本 | ||
cache: 'pip' | ||
|
||
# 缓存 pip 依赖 | ||
- name: Cache pip packages | ||
- name: Cache deps | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
|
||
# 安装依赖 | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
# 执行任务 | ||
- name: Run sign in script | ||
- name: Run script | ||
env: | ||
USER: ${{ secrets.USER }} | ||
TZ: Asia/Shanghai # 确保脚本运行时也使用正确的时区 | ||
run: | | ||
python main.py | ||
TZ: Asia/Shanghai | ||
run: python main.py |