Skip to content

Commit 0d0cf7d

Browse files
committed
ci: add copilot help workflow
1 parent ccf5281 commit 0d0cf7d

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Copilot Help
2+
3+
on:
4+
issues:
5+
types: [labeled]
6+
7+
jobs:
8+
copilot-answer:
9+
if: github.event.label.name == 'help wanted'
10+
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write
13+
contents: read
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v5
18+
19+
- name: Install Copilot CLI
20+
run: |
21+
curl -fsSL https://gh.io/copilot-install | bash
22+
echo "$HOME/.local/bin" >> $GITHUB_PATH
23+
24+
- name: Generate response with Copilot CLI
25+
id: copilot
26+
env:
27+
GH_TOKEN: ${{ secrets.COPILOT_PAT }}
28+
run: |
29+
ISSUE_URL="${{ github.event.issue.html_url }}"
30+
31+
PROMPT="You are an AI assistant bot for the project maintainer, helping to answer user questions and issues.
32+
33+
Please read the GitHub issue at ${ISSUE_URL} including all comments. Analyze the entire conversation and provide helpful answers to any unresolved questions in the issue thread.
34+
35+
Your role:
36+
- Act as a knowledgeable assistant representing the project maintainer
37+
- Provide accurate, helpful, and well-researched answers
38+
- Reference the codebase, documentation, and existing solutions when applicable
39+
- Be professional, friendly, and supportive
40+
- If you're uncertain about something, acknowledge it clearly
41+
42+
Important instructions:
43+
1. Your response must be in the same language as the primary language used in the issue discussion. For example, if the issue is discussed in Chinese, respond in Chinese.
44+
2. After your analysis, output your final answer wrapped with special markers:
45+
- Start with: === FINAL ANSWER BEGIN ===
46+
- End with: === FINAL ANSWER END ===
47+
3. The content between these markers should be the clean, well-formatted response to post as a GitHub issue comment."
48+
49+
copilot -p "$PROMPT" --allow-all-tools --silent > response_raw.md
50+
51+
# Extract content between markers
52+
sed -n '/=== FINAL ANSWER BEGIN ===/,/=== FINAL ANSWER END ===/p' response_raw.md | \
53+
sed '1d;$d' > response.md
54+
55+
- name: Post comment to issue
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
gh issue comment ${{ github.event.issue.number }} \
60+
--repo ${{ github.repository }} \
61+
--body-file response.md
62+
63+
- name: Remove help wanted label
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
run: |
67+
gh issue edit ${{ github.event.issue.number }} \
68+
--repo ${{ github.repository }} \
69+
--remove-label "help wanted"

0 commit comments

Comments
 (0)