main
sh 24 lines 1.22 KB
Raw
1 #!/usr/bin/env bash
2 # Minimal safe Ralph tick placeholder for SquadScope
3 set -euo pipefail
4 cd "$(dirname "$0")/.." || exit 1
5 STATE_DIR=".ralph"
6 mkdir -p "$STATE_DIR"
7 LOG="$STATE_DIR/tick_run.log"
8 NOW_ISO=$(date -u +%Y-%m-%dT%H:%M:%SZ)
9 echo "[$NOW_ISO] Safe tick start" >> "$LOG"
10 REPO="jmservera/SquadScope"
11 # Fetch issues and PRs safely; if API returns empty, write empty JSON array
12 if ! gh issue list --repo "$REPO" --state open --limit 200 --json number,title,labels,assignees,updatedAt,url > "$STATE_DIR/issues.json" 2>"$STATE_DIR/gh_issues_err.log"; then
13 echo "[]" > "$STATE_DIR/issues.json"
14 fi
15 if ! gh pr list --repo "$REPO" --state open --limit 200 --json number,title,files,labels,assignees,updatedAt,url,mergeable,mergeStateStatus,reviewDecision,author > "$STATE_DIR/prs.json" 2>"$STATE_DIR/gh_prs_err.log"; then
16 echo "[]" > "$STATE_DIR/prs.json"
17 fi
18 # Write a brief summary to tick log
19 ISSUES_COUNT=$(jq 'length' "$STATE_DIR/issues.json" 2>/dev/null || echo 0)
20 PRS_COUNT=$(jq 'length' "$STATE_DIR/prs.json" 2>/dev/null || echo 0)
21 echo "[$NOW_ISO] Fetched issues: ${ISSUES_COUNT}, PRs: ${PRS_COUNT}" >> "$LOG"
22 # No further actions here; the squad loop or coordinator will process these files.
23 echo "[$NOW_ISO] Safe tick end" >> "$LOG"
24 exit 0