# ═══════════════════════════════════════════════
# 🔺 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
  pull-requests: write
  discussions: write

jobs:
  daily-report:
    name: 生成并发布开发日报
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 50   # 获取最近提交用于日报亮点

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      # ── 生成并发布日报 ──
      - name: 生成开发日报
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_REPOSITORY: ${{ github.repository }}
          DISCUSSION_CATEGORY: "Announcements"
        run: node scripts/generate-daily-report.js

      # ── 直接提交日报存档到 main ──
      - name: 提交日报存档
        run: |
          git config user.name "zhuyuan-bot"
          git config user.email "zhuyuan@guanghulab.com"
          git add docs/daily-reports/ || true
          git diff --staged --quiet || git commit -m "📰 光湖开发日报 · $(TZ='Asia/Shanghai' date '+%Y-%m-%d') [skip ci]"
          git push || true
