-
Notifications
You must be signed in to change notification settings - Fork 17
105 lines (97 loc) · 3.89 KB
/
Copy pathoutreach-loop.yml
File metadata and controls
105 lines (97 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Cron-driven loop that re-prompts Copilot Cloud Agent every 6 hours
# until the linked outreach meta-issue is closed.
#
# When the meta-issue is open and hasn't been commented on by Copilot
# in the last 6 hours, this workflow adds a fresh "@copilot continue"
# comment to wake the agent back up.
#
# The meta-issue's number must be configured as repository variable
# AGENT_OUTREACH_ISSUE.
name: Outreach loop
on:
schedule:
# Every 6 hours at minute 7 (offset to avoid GitHub Actions
# scheduling congestion at :00).
- cron: "7 */6 * * *"
workflow_dispatch:
inputs:
reason:
description: "Why are you triggering this manually?"
required: false
default: "manual nudge"
permissions:
contents: read
issues: write
jobs:
nudge:
runs-on: ubuntu-latest
steps:
- name: Resolve issue numbers
id: cfg
env:
GH_TOKEN: ${{ github.token }}
run: |
OUTREACH="${{ vars.AGENT_OUTREACH_ISSUE }}"
A2A="${{ vars.AGENT_A2A_ISSUE }}"
if [ -z "$OUTREACH" ] && [ -z "$A2A" ]; then
echo "::warning::No agent issues configured; skipping"
echo "skip=true" >> $GITHUB_OUTPUT
exit 0
fi
# Build a space-separated list of "issue|label" pairs
PAIRS=""
if [ -n "$OUTREACH" ]; then PAIRS="$OUTREACH:outreach"; fi
if [ -n "$A2A" ]; then
if [ -n "$PAIRS" ]; then PAIRS="$PAIRS $A2A:a2a"; else PAIRS="$A2A:a2a"; fi
fi
echo "pairs=$PAIRS" >> $GITHUB_OUTPUT
- name: Nudge agents on stale issues
if: steps.cfg.outputs.skip != 'true'
env:
GH_TOKEN: ${{ github.token }}
PAIRS: ${{ steps.cfg.outputs.pairs }}
REPO: ${{ github.repository }}
run: |
for PAIR in $PAIRS; do
ISSUE="${PAIR%:*}"
LABEL="${PAIR#*:}"
echo "::group::Checking issue #$ISSUE ($LABEL)"
STATE=$(gh issue view "$ISSUE" --repo "$REPO" --json state -q .state)
if [ "$STATE" != "OPEN" ]; then
echo "Issue #$ISSUE not open; skipping."
echo "::endgroup::"
continue
fi
LAST=$(gh issue view "$ISSUE" --repo "$REPO" \
--json comments -q '.comments | sort_by(.createdAt) | last | .createdAt')
if [ -z "$LAST" ] || [ "$LAST" = "null" ]; then
echo "No comments yet on #$ISSUE; nudging."
NEEDS_NUDGE="true"
else
NOW=$(date -u +%s)
LAST_TS=$(date -u -d "$LAST" +%s 2>/dev/null || date -u -j -f "%Y-%m-%dT%H:%M:%SZ" "$LAST" +%s)
DELTA=$(( NOW - LAST_TS ))
if [ "$DELTA" -gt 19800 ]; then
echo "Issue #$ISSUE last activity $DELTA seconds ago; nudging."
NEEDS_NUDGE="true"
else
echo "Issue #$ISSUE last activity $DELTA seconds ago; no nudge needed."
NEEDS_NUDGE="false"
fi
fi
if [ "$NEEDS_NUDGE" = "true" ]; then
case "$LABEL" in
outreach)
MSG="@copilot continue working on the outreach loop. Pick the next unchecked task above and proceed per the try/fail/retry rules. Cycle: $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
;;
a2a)
MSG="@copilot continue working on the A2A discoverability task. Pick the next unchecked item from the current phase, complete the phase before starting the next, and proceed per the try/fail/retry rules. Cycle: $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
;;
*)
MSG="@copilot continue working on this task. Cycle: $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
;;
esac
gh issue comment "$ISSUE" --repo "$REPO" --body "$MSG"
fi
echo "::endgroup::"
done