Observer Auto-Trigger #96
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: Observer Auto-Trigger | |
| # Observer 定期扫描 Issues 并自主决定是否触发评审 | |
| on: | |
| schedule: | |
| # 每小时运行一次 | |
| - cron: '0 * * * *' | |
| workflow_dispatch: # 允许手动触发 | |
| # 并发控制:避免多次扫描堆积 | |
| concurrency: | |
| group: observer-scan | |
| cancel-in-progress: false | |
| permissions: | |
| issues: write | |
| contents: read | |
| jobs: | |
| observer-scan: | |
| # 仅在主仓库运行,避免在fork仓库中不必要的定时执行 | |
| if: github.repository == 'gqy20/IssueLab' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: '3.13' | |
| enable-cache: true | |
| - run: uv sync | |
| - name: Get open issues | |
| id: get_issues | |
| run: | | |
| # 获取所有开放的 issues(排除已标记为 processing 或 quiet 的) | |
| gh issue list \ | |
| --json number,labels \ | |
| --jq '.[] | select( | |
| (.labels | map(.name) | contains(["bot:processing", "bot:quiet"]) | not) | |
| ) | .number' \ | |
| > /tmp/issue_numbers.txt | |
| # 读取 issue 编号并转为逗号分隔 | |
| ISSUE_NUMBERS=$(cat /tmp/issue_numbers.txt | tr '\n' ',' | sed 's/,$//') | |
| ISSUE_COUNT=$(wc -l < /tmp/issue_numbers.txt) | |
| echo "找到 $ISSUE_COUNT 个待观察的 issues: $ISSUE_NUMBERS" | |
| echo "issue_count=$ISSUE_COUNT" >> $GITHUB_OUTPUT | |
| echo "issue_numbers=$ISSUE_NUMBERS" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} | |
| - name: Run Observer for all issues (parallel) | |
| if: steps.get_issues.outputs.issue_count > 0 | |
| run: | | |
| echo "=== 并行分析 ${{ steps.get_issues.outputs.issue_count }} 个 Issues ===" | |
| # 使用新的 auto-trigger 参数替代 --post(避免bot评论触发问题) | |
| uv run python -m issuelab observe-batch \ | |
| --issues "${{ steps.get_issues.outputs.issue_numbers }}" \ | |
| --max-parallel 5 \ | |
| --auto-trigger | |
| echo "=== 分析完成 ===" | |
| env: | |
| GH_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }} | |
| ANTHROPIC_AUTH_TOKEN: ${{ secrets.ANTHROPIC_AUTH_TOKEN }} | |
| ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL || 'https://api.minimaxi.com/anthropic' }} | |
| ANTHROPIC_MODEL: ${{ secrets.ANTHROPIC_MODEL || 'MiniMax-M2.1' }} | |
| GITHUB_APP_ID: ${{ secrets.ISSUELAB_APP_ID }} | |
| GITHUB_APP_PRIVATE_KEY: ${{ secrets.ISSUELAB_APP_PRIVATE_KEY }} | |
| LOG_FILE: ${{ github.workspace }}/logs/observer_${{ github.run_id }}.log | |
| LOG_LEVEL: DEBUG | |
| MCP_LOG_DETAIL: "1" | |
| PROMPT_LOG: "1" | |
| - uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: observer-logs-${{ github.run_id }} | |
| path: logs/ | |
| retention-days: 7 |