newapi.ai 自动签到 #12
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: | |
| jobs: | |
| checkin: | |
| permissions: | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| environment: production | |
| env: | |
| PYTHONIOENCODING: utf-8 | |
| steps: | |
| - 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: 获取 Playwright 版本 | |
| id: playwright-version | |
| run: | | |
| version=$(uv run python -c "import importlib.metadata; print(importlib.metadata.version('playwright'))") | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| echo "Playwright version: $version" | |
| - name: 缓存 Playwright 浏览器 | |
| uses: actions/cache@v4 | |
| id: playwright-cache | |
| with: | |
| path: ~/.cache/playwright | |
| key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }} | |
| restore-keys: | | |
| ${{ runner.os }}-playwright- | |
| - name: 安装 Playwright 浏览器 | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| run: | | |
| echo "缓存未命中,开始安装 Playwright 浏览器..." | |
| uv run playwright install chromium --with-deps | |
| - name: 恢复登录状态缓存 | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| caches | |
| key: auth-caches-${{ github.sha }} | |
| restore-keys: | | |
| auth-caches- | |
| - name: 恢复余额历史缓存 | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| balance_hash.txt | |
| key: balance-hash-${{ github.sha }} | |
| restore-keys: | | |
| balance-hash- | |
| - uses: step-security/wait-for-secrets@v1 | |
| id: get-otp | |
| with: | |
| secrets: | | |
| DUMMY_SECRET: | |
| name: 'Dummy secret' | |
| description: 'Dummy secret to demo wait-for-secrets' | |
| - run: | | |
| echo ${{ steps.get-otp.outputs.DUMMY_SECRET }} | |
| - name: 执行签到 | |
| env: | |
| ACCOUNTS: ${{ secrets.ACCOUNTS }} | |
| PROVIDERS: ${{ secrets.PROVIDERS }} | |
| 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 }} | |
| run: | | |
| uv run main.py | |
| - name: 执行结果 | |
| if: always() | |
| run: | | |
| echo "签到任务执行完成" | |
| echo "时间: $(date)" |