Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 12 additions & 42 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,48 +1,18 @@
# NewAPI 账号配置示例
# 复制此文件为 .env 并填入实际值(仅用于本地测试)
# NewAPI Runner 环境变量示例
# 账号在 Worker 控制台统一管理,GitHub Actions 只需要以下两个必填值。

# ========== 云端配置(推荐)==========
# 优先级高于 NEWAPI_ACCOUNTS,配置文件存放在云盘/NAS,改配置无需推代码
# CONFIG_URL=https://dav.jianguoyun.com/dav/your@email.com/newapi-config.json
# CONFIG_AUTH=your@email.com:your_app_password
# 部署后的 Worker 根地址,不带末尾斜杠
CHECKIN_WORKER_URL=https://newapi-checkin.your-subdomain.workers.dev

# ========== 认证格式说明 ==========
# 坚果云: CONFIG_AUTH=邮箱:应用专用密码(账户设置 → 安全选项 → 第三方应用密码)
# 群晖 NAS: CONFIG_AUTH=用户名:密码(需启用 WebDAV 服务)
# NextCloud: CONFIG_AUTH=用户名:密码 或 CONFIG_AUTH=token:访问令牌
# 直接链接: CONFIG_AUTH=(如果链接无需认证则留空)
# 自行生成,并与 Cloudflare Worker 的 RUNNER_TOKEN 完全一致
# 生成命令:openssl rand -hex 32
CHECKIN_RUNNER_TOKEN=replace-with-a-64-character-hex-token

# ========== 单账号格式 ==========
NEWAPI_ACCOUNTS=https://your-domain.com#your_session_cookie

# ========== 多网站格式(逗号分隔)==========
# 支持多个不同的 NewAPI 站点
# NEWAPI_ACCOUNTS=https://site1.com#session1,https://site2.com#session2,https://site3.com#session3

# ========== JSON 格式(推荐)==========
# 支持多网站、用户ID、备注名称、更好的可读性
# NEWAPI_ACCOUNTS=[{"url":"https://api.example.com","session":"sess1","user_id":"123","name":"主力站"},{"url":"https://api2.example.com","session":"sess2","user_id":"456","name":"备用站"}]

# ========== JSON 格式 + CF 绕过 ==========
# cf_clearance 可手动提供(可选,Playwright 自动绕过时不需要)
# NEWAPI_ACCOUNTS=[{"url":"https://cf-protected-site.com","session":"sess1","cf_clearance":"cf_clearance_value","name":"CF站点"}]

# ========== 完整示例 ==========
# 替换下面的值为你自己的真实配置
# NEWAPI_ACCOUNTS=[{"url":"https://api.example.com","session":"MTc2NzQxMzYzM3xEWDhFQVFMX2dBQUJFQUVRQUFE...","user_id":"123","name":"主力站"},{"url":"https://api2.example.com","session":"QVFMXzJhYWJFRUFRQUFEX3dfLUFBQVlHYzNSeWFXNW5EQTBBQzI...","user_id":"456","name":"备用站"}]

# ========== 钉钉通知配置 ==========

# 钉钉机器人 Webhook URL(可选,配置后启用通知)
# 可选:钉钉通知
# DINGTALK_WEBHOOK=https://oapi.dingtalk.com/robot/send?access_token=xxxxx

# 钉钉机器人签名密钥(可选,如果开启了加签安全设置)
# DINGTALK_SECRET=SECxxxxx

# ========== Cloudflare 绕过说明 ==========
# 本项目支持自动绕过 Cloudflare 防护:
# - 默认使用 requests 直连(快速模式)
# - 检测到 CF 拦截时自动切换 Playwright 无头浏览器
# - GitHub Actions 已配置 Playwright 安装步骤
# - 本地运行需手动安装: pip install playwright && playwright install chromium
# - cf_clearance 字段仍可手动配置作为备用
# 可选:兼容模式回退配置
# NEWAPI_ACCOUNTS=[{"url":"https://api.example.com","session":"session-value","name":"主力站"}]
# CONFIG_URL=https://example.com/newapi-config.json
# CONFIG_AUTH=username:password
15 changes: 11 additions & 4 deletions .github/workflows/checkin.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
name: NewAPI 自动签到

on:
# 定时执行:每天 UTC 0:10 (北京时间 8:10)
# 每天 UTC 0:10 执行一次(北京时间约 8:10)。GitHub schedule 可能延迟。
schedule:
- cron: '10 0 * * *'
# 手动触发
workflow_dispatch:

permissions:
contents: read

concurrency:
group: newapi-checkin
cancel-in-progress: false

jobs:
checkin:
runs-on: ubuntu-latest
timeout-minutes: 90

steps:
- name: 检出代码
Expand All @@ -28,9 +36,8 @@ jobs:

- name: 执行签到
env:
CONFIG_URL: ${{ secrets.CONFIG_URL }}
CONFIG_AUTH: ${{ secrets.CONFIG_AUTH }}
NEWAPI_ACCOUNTS: ${{ secrets.NEWAPI_ACCOUNTS }}
CHECKIN_WORKER_URL: ${{ secrets.CHECKIN_WORKER_URL }}
CHECKIN_RUNNER_TOKEN: ${{ secrets.CHECKIN_RUNNER_TOKEN }}
DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }}
DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }}
run: python checkin.py
18 changes: 11 additions & 7 deletions .github/workflows/keepalive.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
name: Keepalive Workflow
name: Scheduled Workflow Check

# 防止 GitHub Actions 在 60 天不活动后自动禁用工作流
# 每 50 天运行一次,保持工作流活跃
# 定期输出工作流状态。此运行不计为仓库活动,无法阻止 GitHub
# 对长期无仓库活动的公开仓库停用 scheduled workflows。

on:
schedule:
# 每 50 天运行一次 (每月 1 日和 21 日 UTC 1:00)
# 每月 1 日和 21 日 UTC 1:00 运行
- cron: '0 1 1,21 * *'
# 手动触发
workflow_dispatch:

permissions:
contents: read

jobs:
keepalive:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: 检出代码
uses: actions/checkout@v4

- name: 保持工作流活跃
- name: 输出计划任务状态
run: |
echo "Keepalive ping at $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo "This workflow prevents GitHub from automatically disabling scheduled workflows."
echo "Scheduled workflow check at $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo "Repository activity is still required to keep scheduled workflows enabled."
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ env/
.spec-workflow
.claude/
.serena/
.monkeycode/

# OS
.DS_Store
Thumbs.db

# 配置文件(包含敏感信息)
.env
worker/.dev.vars
worker/.wrangler/
config.json
accounts.json
newapi_accounts.json
Expand Down
12 changes: 12 additions & 0 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"config": {
"MD013": false,
"MD024": {
"siblings_only": true
},
"MD033": {
"allowed_elements": ["div", "strong", "br"]
},
"MD060": false
}
}
Loading