# ═══════════════════════════════════════════════
# 🔺 Sovereign: TCS-0002∞ | Root: SYS-GLW-0001
# 📜 Copyright: 国作登字-2026-A-00037559
# ═══════════════════════════════════════════════
name: 人格体每日签到
on:
  schedule:
    - cron: '0 2 * * *'  # UTC 02:00 = 北京 10:00
  workflow_dispatch:

permissions:
  contents: write
  actions: read

jobs:
  checkin:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # 🌊 进入光湖
      - name: 🌊 进入光湖
        uses: ./.github/actions/guanghu-shell
        with:
          agent_id: 'AG-ZY-001'
          action: 'enter'

      - name: 执行签到任务
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: node scripts/agent-checkin.js

      - name: 提交签到记录
        run: |
          git config user.name "铸渊"
          git config user.email "zhuyuan@guanghulab.com"
          git add .github/persona-brain/checkin-board.json .github/brain/shell-status.json .github/brain/shell-errors.json
          git commit -m "[AG-ZY] 每日签到记录 $(date +'%Y-%m-%d')" || echo "无变更"
          git push

      # 🌊 离开光湖（成功时）
      - name: 🌊 离开光湖
        if: success()
        uses: ./.github/actions/guanghu-shell
        with:
          agent_id: 'AG-ZY-001'
          action: 'exit'
          detail: 'checkin completed'

      # 🌊 异常上报（失败时）
      - name: 🌊 异常上报
        if: failure()
        uses: ./.github/actions/guanghu-shell
        with:
          agent_id: 'AG-ZY-001'
          action: 'error'
          detail: 'checkin workflow failed'
