forked from 0GiS0/ADO_CodingAgent
-
Notifications
You must be signed in to change notification settings - Fork 3
240 lines (204 loc) · 8.91 KB
/
copilot-coder.yml
File metadata and controls
240 lines (204 loc) · 8.91 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: 🤖 GitHub Copilot Coder
on:
issues:
types: [labeled]
jobs:
copilot-cli:
# Only run when the issue has the 'copilot' label
if: contains(github.event.issue.labels.*.name, 'copilot')
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
env:
MODEL: claude-haiku-4.5
COPILOT_VERSION: 0.0.352
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_ASSIGNEE: ${{ github.event.issue.assignee.login }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
REPO_NAME: ${{ github.repository }}
BRANCH_NAME: copilot/${{ github.event.issue.number }}
steps:
- name: 🚀 Start Workflow
run: |
echo "🚀 GitHub Copilot Coder workflow started!"
echo "═══════════════════════════════════════════════════════════"
echo "📋 Issue: #${ISSUE_NUMBER}"
echo "📌 Title: ${ISSUE_TITLE}"
echo "👤 Creator: ${ISSUE_CREATOR}"
echo "📦 Repository: ${REPO_NAME}"
echo "🌿 Branch: ${BRANCH_NAME}"
echo "═══════════════════════════════════════════════════════════"
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
REPO_NAME: ${{ github.repository }}
BRANCH_NAME: copilot/${{ github.event.issue.number }}
- name: 📥 Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: 🏷️ Update Issue Labels - In Progress
run: |
gh issue edit ${{ env.ISSUE_NUMBER }} \
--add-label "in-progress" \
--remove-label "copilot"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: 🐍 Setup Python (Latest)
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: 📦 Install uv/uvx
run: |
echo "Installing uvx (pipx runner)..."
pip install --upgrade pip
pip install uv
echo "✅ Python and uv installed"
python --version
uv --version
- name: ⚙️ Setup Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: 🔍 Detect NPM Global Path
id: npm-path
run: |
NPM_PREFIX=$(npm config get prefix)
echo "NPM_GLOBAL_PATH=${NPM_PREFIX}/lib/node_modules" >> $GITHUB_ENV
echo "NPM global path: ${NPM_PREFIX}/lib/node_modules"
- name: 📦 Cache Global NPM Packages
uses: actions/cache@v4
with:
key: npm-global-${{ runner.os }}-copilot-${{ env.COPILOT_VERSION }}
path: ${{ env.NPM_GLOBAL_PATH }}
restore-keys: |
npm-global-${{ runner.os }}-copilot-
- name: 📦 Install Copilot CLI
run: |
if ! command -v copilot &> /dev/null; then
echo "Installing @github/copilot@${{ env.COPILOT_VERSION }}..."
npm install -g @github/copilot@${{ env.COPILOT_VERSION }}
else
echo "✅ @github/copilot already installed (from cache)"
copilot --version
fi
- name: ⚙️ Configure MCP Servers
run: |
mkdir -p ~/.config
cp mcp-config.json ~/.config/mcp-config.json
echo "✅ MCP configuration copied to ~/.config/mcp-config.json"
cat ~/.config/mcp-config.json
- name: 🧰 Check MCP Access
run: |
echo "🧰 Verifying MCP server access..."
copilot -p "List tools defined in the current chat session (do not run commands, I am asking about tools defined in the LLM). Just the names in a table, nothing else." --allow-all-tools
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
- name: 🌿 Create Feature Branch
run: |
echo "🌿 Creating feature branch..."
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b ${{ env.BRANCH_NAME }}
echo "✅ Branch ${{ env.BRANCH_NAME }} created"
- name: 🤖 Implement Changes with Copilot
run: |
echo "🤖 Running GitHub Copilot CLI..."
echo "═══════════════════════════════════════════════════════════"
echo "📋 Issue: #${ISSUE_NUMBER}"
echo "📌 Title: ${ISSUE_TITLE}"
echo "═══════════════════════════════════════════════════════════"
echo "This is the description that Copilot CLI is going to use to implement the task:"
echo "${ISSUE_BODY}"
mkdir -p logs
# Save issue body to file to avoid injection
printf '%s' "${ISSUE_BODY}" > /tmp/issue_description.txt
# Run Copilot with file input
copilot -p "Implement the GitHub issue following the description details: $(cat /tmp/issue_description.txt)" \
--allow-all-tools \
--log-level all \
--log-dir logs \
--model "${MODEL}"
# Clean up
rm -f /tmp/issue_description.txt
echo "✅ Implementation completed"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
MODEL: ${{ env.MODEL }}
- name: 💾 Commit Changes
run: |
./scripts/prepare-commit.sh "${ISSUE_NUMBER}" "${ISSUE_TITLE}" "${ISSUE_CREATOR}"
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
- name: 🚀 Push Branch
run: |
./scripts/push-branch.sh "${{ env.BRANCH_NAME }}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: 📬 Create Pull Request
id: create-pr
run: |
# Check if copilot-summary.md exists
if [ -f "copilot-summary.md" ]; then
PR_BODY=$(cat copilot-summary.md)
else
PR_BODY="## 🤖 Automated Implementation
This PR was automatically generated by GitHub Copilot CLI.
### 📋 Related Issue
Closes #${ISSUE_NUMBER}
### 📝 Changes
Please review the changes made by Copilot CLI."
fi
# Save PR body to file to avoid injection
printf '%s' "${PR_BODY}" > /tmp/pr_body.txt
# Create PR and capture URL - use file for body
PR_URL=$(gh pr create \
--title "${ISSUE_TITLE}" \
--body-file /tmp/pr_body.txt \
--base main \
--head "${BRANCH_NAME}" \
--label "copilot-generated" \
--assignee "${ISSUE_CREATOR}")
# Clean up
rm -f /tmp/pr_body.txt
echo "PR_URL=${PR_URL}" >> $GITHUB_ENV
echo "✅ Pull Request created: ${PR_URL}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_CREATOR: ${{ github.event.issue.user.login }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
- name: 💬 Add Completion Comment to Issue
run: |
./scripts/post-workflow-comment.sh "${ISSUE_NUMBER}" "${PR_URL}"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
PR_URL: ${{ env.PR_URL }}
- name: 🏷️ Update Issue Labels - Completed
run: |
gh issue edit ${{ env.ISSUE_NUMBER }} \
--add-label "completed,ready-for-review" \
--remove-label "in-progress"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: 📦 Publish Logs
uses: actions/upload-artifact@v4
if: always()
with:
name: copilot-logs
path: logs/
retention-days: 30