newapi.ai 自动签到 #632
This file contains hidden or 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
| name: newapi.ai 自动签到 | |
| on: | |
| schedule: | |
| - cron: '0 */8 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| accounts: | |
| description: '账号配置 (JSON 格式,可选,不填则使用 secrets.ACCOUNTS)' | |
| required: false | |
| type: string | |
| default: '' | |
| providers: | |
| description: '自定义 Provider 配置 (JSON 格式,可选,不填则使用 secrets.PROVIDERS)' | |
| required: false | |
| type: string | |
| default: '' | |
| debug: | |
| description: '调试模式 (启用后会保存截图和 HTML 日志)' | |
| required: false | |
| type: boolean | |
| jobs: | |
| checkin: | |
| permissions: | |
| id-token: write | |
| contents: read | |
| runs-on: windows-2025 | |
| environment: production | |
| env: | |
| PYTHONIOENCODING: utf-8 | |
| steps: | |
| - name: set beijing timezone | |
| uses: szenius/set-timezone@v2.0 | |
| with: | |
| timezoneWindows: "China Standard Time" | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: 缓存 UV 依赖 | |
| uses: actions/cache@v4 | |
| id: uv-cache | |
| with: | |
| path: | | |
| ~/.cache/uv | |
| .venv | |
| key: ${{ runner.os }}-uv-${{ hashFiles('pyproject.toml', 'uv.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv- | |
| - name: 安装依赖 | |
| if: steps.uv-cache.outputs.cache-hit != 'true' | |
| run: | | |
| echo "缓存未命中,开始安装项目依赖..." | |
| uv sync | |
| echo "✅ 环境初始化完成" | |
| - name: 获取 Camoufox 版本 | |
| id: camoufox-version | |
| run: | | |
| $version = uv run python -c "import importlib.metadata; print(importlib.metadata.version('camoufox'))" | |
| echo "version=$version" >> $env:GITHUB_OUTPUT | |
| echo "Camoufox version: $version" | |
| - name: 缓存 Camoufox 浏览器 | |
| uses: actions/cache@v4 | |
| id: camoufox-cache | |
| with: | |
| path: ~\AppData\Local\camoufox | |
| key: ${{ runner.os }}-camoufox-${{ steps.camoufox-version.outputs.version }} | |
| restore-keys: | | |
| ${{ runner.os }}-camoufox- | |
| - name: 安装 Camoufox 浏览器 | |
| if: steps.camoufox-cache.outputs.cache-hit != 'true' | |
| run: | | |
| echo "缓存未命中,开始下载 Camoufox 浏览器..." | |
| uv run camoufox fetch | |
| echo "✅ Camoufox 浏览器安装完成" | |
| - name: 恢复登录状态缓存 | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| storage-states | |
| key: storage-state-${{ hashFiles('storage-states/*.json') }} | |
| restore-keys: | | |
| storage-state- | |
| - name: 恢复余额历史缓存 | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| balance_hash.txt | |
| key: balance-hash-${{ hashFiles('balance_hash.txt') }} | |
| restore-keys: | | |
| balance-hash- | |
| - name: 执行签到 | |
| env: | |
| ACCOUNTS: ${{ inputs.accounts || secrets.ACCOUNTS }} | |
| ACCOUNTS_LINUX_DO: ${{ secrets.ACCOUNTS_LINUX_DO }} | |
| ACCOUNTS_GITHUB: ${{ secrets.ACCOUNTS_GITHUB }} | |
| PROVIDERS: ${{ inputs.providers || secrets.PROVIDERS }} | |
| PROXY: ${{secrets.PROXY}} | |
| DEBUG: ${{ github.event_name == 'workflow_dispatch' && inputs.debug || vars.DEBUG || 'false' }} | |
| DINGDING_WEBHOOK: ${{ secrets.DINGDING_WEBHOOK }} | |
| EMAIL_USER: ${{ secrets.EMAIL_USER }} | |
| EMAIL_PASS: ${{ secrets.EMAIL_PASS }} | |
| EMAIL_TO: ${{ secrets.EMAIL_TO }} | |
| CUSTOM_SMTP_SERVER: ${{ secrets.CUSTOM_SMTP_SERVER }} | |
| PUSHPLUS_TOKEN: ${{ secrets.PUSHPLUS_TOKEN }} | |
| SERVERPUSHKEY: ${{ secrets.SERVERPUSHKEY }} | |
| FEISHU_WEBHOOK: ${{ secrets.FEISHU_WEBHOOK }} | |
| WEIXIN_WEBHOOK: ${{ secrets.WEIXIN_WEBHOOK }} | |
| TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
| TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
| run: | | |
| # 列出 storage-states 目录文件 | |
| if (Test-Path "storage-states") { | |
| echo "📁 storage-states 目录内容:" | |
| echo "绝对路径: $(Resolve-Path storage-states)" | |
| echo "" | |
| echo "所有文件:" | |
| Get-ChildItem -Path storage-states -File | ForEach-Object { echo " - $($_.Name)" } | |
| echo "" | |
| echo "详细信息:" | |
| Get-ChildItem -Path storage-states -File | Format-Table Name, Length, LastWriteTime -AutoSize | |
| echo "文件总数: $((Get-ChildItem -Path storage-states -File).Count)" | |
| } else { | |
| echo "⚠️ storage-states 目录不存在" | |
| } | |
| # 执行签到 | |
| uv run python -u main.py | |
| - name: 保存登录状态缓存 | |
| if: hashFiles('storage-states/*.json') != '' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| storage-states | |
| key: storage-state-${{ hashFiles('storage-states/*.json') }} | |
| - name: 保存余额历史缓存 | |
| if: hashFiles('balance_hash.txt') != '' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: | | |
| balance_hash.txt | |
| key: balance-hash-${{ hashFiles('balance_hash.txt') }} | |
| - name: 保存日志 | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: artifacts-${{ github.run_number }} | |
| path: | | |
| logs/ | |
| screenshots/ | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| - name: 执行结果 | |
| if: always() | |
| run: | | |
| echo "签到任务执行完成" | |
| echo "时间: $(Get-Date)" |