name: Copilot CI Watchdog # app/copilot-swe-agent が作成した PR の CI/AI-review が # "action_required" (0 jobs) でブロックされる構造的問題を自動修復する。 # # 根本原因: # GitHub が app/copilot-swe-agent を "outside collaborator" と判定し、 # pull_request トリガーのワークフローを実行前にブロックする。 # → action_required (0 jobs) となり CI/AI-review が一切動かない。 # # 対策: # 15分ごとに copilot/** ブランチの action_required ランを自動 rerun する。 # rerun は GITHUB_TOKEN で実行できるため人手不要。 on: schedule: - cron: '*/15 * * * *' workflow_dispatch: permissions: actions: write jobs: watchdog: name: Re-run blocked Copilot workflows runs-on: ubuntu-latest steps: - name: Re-run action_required CI and AI Review runs env: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail REPO="${{ github.repository }}" RERUN_COUNT=0 for WF in "CI" "AI Code Review"; do echo "=== Checking: $WF ===" IDS=$(gh run list --repo "$REPO" --workflow "$WF" --limit 20 \ --json databaseId,conclusion,headBranch,createdAt \ --jq '[group_by(.headBranch)[] | max_by(.createdAt) | select(.conclusion == "action_required" and (.headBranch | startswith("copilot/")))] | .[].databaseId' \ 2>/dev/null || true) if [ -z "$IDS" ]; then echo " No blocked runs for \"$WF\"" continue fi while IFS= read -r RUN_ID; do [ -z "$RUN_ID" ] && continue echo " Rerunning run #$RUN_ID ($WF)..." gh run rerun "$RUN_ID" --repo "$REPO" 2>&1 && RERUN_COUNT=$((RERUN_COUNT + 1)) || echo " -> Skipped (already running or not rerunnable)" done <<< "$IDS" done echo "" echo "Total reruns triggered: $RERUN_COUNT" if [ "$RERUN_COUNT" -eq 0 ]; then echo "All Copilot workflows are healthy." fi