-
Notifications
You must be signed in to change notification settings - Fork 4
181 lines (153 loc) · 6.98 KB
/
weekly-reference-impl-sync.yml
File metadata and controls
181 lines (153 loc) · 6.98 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: "Weekly Reference Implementation Sync"
on:
schedule:
# Every Monday at 10:00 UTC (5:00 AM EST / 6:00 AM EDT)
- cron: '0 10 * * 1'
workflow_dispatch:
permissions:
contents: write
issues: write
pull-requests: write
env:
# Used for `gh` CLI operations to create/close/comment issues. Must be a PAT with repo permissions because the default
GH_AW_AGENT_TOKEN: ${{ secrets.GH_AW_AGENT_TOKEN }}
GH_TOKEN: ${{ secrets.GH_AW_AGENT_TOKEN }}
jobs:
check-and-sync:
name: "Check reference implementation & trigger Copilot merge"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check for reference implementation changes
id: check
run: |
LAST_MERGE=$(cat .lastmerge)
echo "Last merged commit: $LAST_MERGE"
git clone --quiet https://github.com/github/copilot-sdk.git /tmp/reference-impl
cd /tmp/reference-impl
REFERENCE_IMPL_HEAD=$(git rev-parse HEAD)
echo "Reference implementation HEAD: $REFERENCE_IMPL_HEAD"
echo "last_merge=$LAST_MERGE" >> "$GITHUB_OUTPUT"
if [ "$LAST_MERGE" = "$REFERENCE_IMPL_HEAD" ]; then
echo "No new reference implementation changes since last merge."
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
COMMIT_COUNT=$(git rev-list --count "$LAST_MERGE".."$REFERENCE_IMPL_HEAD")
echo "Found $COMMIT_COUNT new reference implementation commits."
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "commit_count=$COMMIT_COUNT" >> "$GITHUB_OUTPUT"
echo "reference_impl_head=$REFERENCE_IMPL_HEAD" >> "$GITHUB_OUTPUT"
# Generate a short summary of changes
SUMMARY=$(git log --oneline "$LAST_MERGE".."$REFERENCE_IMPL_HEAD" | head -20)
{
echo "summary<<EOF"
echo "$SUMMARY"
echo "EOF"
} >> "$GITHUB_OUTPUT"
fi
- name: Close previous reference-impl-sync issues
if: steps.check.outputs.has_changes == 'true'
run: |
# Find all open issues with the reference-impl-sync label
OPEN_ISSUES=$(gh issue list \
--repo "${{ github.repository }}" \
--label "reference-impl-sync" \
--state open \
--json number \
--jq '.[].number')
for ISSUE_NUM in $OPEN_ISSUES; do
echo "Closing superseded issue #${ISSUE_NUM}"
gh issue comment "$ISSUE_NUM" \
--repo "${{ github.repository }}" \
--body "Superseded by a newer reference implementation sync issue. Closing this one."
gh issue close "$ISSUE_NUM" \
--repo "${{ github.repository }}" \
--reason "not planned"
done
- name: Close stale reference-impl-sync issues (no changes)
if: steps.check.outputs.has_changes == 'false'
run: |
OPEN_ISSUES=$(gh issue list \
--repo "${{ github.repository }}" \
--label "reference-impl-sync" \
--state open \
--json number \
--jq '.[].number')
for ISSUE_NUM in $OPEN_ISSUES; do
echo "Closing stale issue #${ISSUE_NUM} — reference implementation is up to date"
gh issue comment "$ISSUE_NUM" \
--repo "${{ github.repository }}" \
--body "No new reference implementation changes detected. The Java SDK is up to date. Closing."
gh issue close "$ISSUE_NUM" \
--repo "${{ github.repository }}" \
--reason "completed"
done
- name: Create issue and assign to Copilot
id: create-issue
if: steps.check.outputs.has_changes == 'true'
env:
SUMMARY: ${{ steps.check.outputs.summary }}
run: |
COMMIT_COUNT="${{ steps.check.outputs.commit_count }}"
LAST_MERGE="${{ steps.check.outputs.last_merge }}"
REFERENCE_IMPL_HEAD="${{ steps.check.outputs.reference_impl_head }}"
DATE=$(date -u +"%Y-%m-%d")
REPO="${{ github.repository }}"
BODY="## Automated Reference Implementation Sync
There are **${COMMIT_COUNT}** new commits in the [official Copilot SDK](https://github.com/github/copilot-sdk) since the last merge.
- **Last merged commit:** [\`${LAST_MERGE}\`](https://github.com/github/copilot-sdk/commit/${LAST_MERGE})
- **Reference implementation HEAD:** [\`${REFERENCE_IMPL_HEAD}\`](https://github.com/github/copilot-sdk/commit/${REFERENCE_IMPL_HEAD})
### Recent reference implementation commits
\`\`\`
${SUMMARY}
\`\`\`
### Instructions
Follow the [agentic-merge-reference-impl](.github/prompts/agentic-merge-reference-impl.prompt.md) prompt to port these changes to the Java SDK."
# Create the issue and assign to Copilot coding agent
ISSUE_URL=$(gh issue create \
--repo "$REPO" \
--title "Reference implementation sync: ${COMMIT_COUNT} new commits (${DATE})" \
--body "$BODY" \
--label "reference-impl-sync" \
--assignee "copilot-swe-agent")
echo "issue_url=$ISSUE_URL" >> "$GITHUB_OUTPUT"
echo "✅ Issue created and assigned to Copilot coding agent: $ISSUE_URL"
- name: Summary
if: always()
env:
SUMMARY: ${{ steps.check.outputs.summary }}
run: |
HAS_CHANGES="${{ steps.check.outputs.has_changes }}"
COMMIT_COUNT="${{ steps.check.outputs.commit_count }}"
LAST_MERGE="${{ steps.check.outputs.last_merge }}"
REFERENCE_IMPL_HEAD="${{ steps.check.outputs.reference_impl_head }}"
ISSUE_URL="${{ steps.create-issue.outputs.issue_url }}"
{
echo "## Weekly Reference Implementation Sync"
echo ""
if [ "$HAS_CHANGES" = "true" ]; then
echo "### ✅ New reference implementation changes detected"
echo ""
echo "| | |"
echo "|---|---|"
echo "| **New commits** | ${COMMIT_COUNT} |"
echo "| **Last merged** | \`${LAST_MERGE:0:12}\` |"
echo "| **Reference implementation HEAD** | \`${REFERENCE_IMPL_HEAD:0:12}\` |"
echo ""
echo "An issue has been created and assigned to the Copilot coding agent: "
echo " -> ${ISSUE_URL}"
echo ""
echo "### Recent reference implementation commits"
echo ""
echo '```'
echo "$SUMMARY"
echo '```'
else
echo "### ⏭️ No changes"
echo ""
echo "The Java SDK is already up to date with the reference implementation Copilot SDK."
echo ""
echo "**Last merged commit:** \`${LAST_MERGE:0:12}\`"
fi
} >> "$GITHUB_STEP_SUMMARY"