Skip to content

Commit 4597726

Browse files
authored
fix: support using GH token (#1594)
1 parent c1199cc commit 4597726

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

.github/agents/issuelens.agent.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,34 @@ The comment should include, in order:
4040
</details>
4141
```
4242
43-
Post the comment on the issue using `github/add_issue_comment`.
43+
Post the comment on the issue by writing and executing the following Python script inline. The script reads `GITHUB_TOKEN` (or `GITHUB_ACCESS_TOKEN`) from the environment.
44+
45+
```python
46+
import os, sys, requests
47+
48+
def add_issue_comment(owner, repo, issue_number, body):
49+
token = (
50+
os.environ.get("GITHUB_TOKEN")
51+
or os.environ.get("GITHUB_ACCESS_TOKEN")
52+
or os.environ.get("GITHUB_PAT")
53+
)
54+
if not token:
55+
print("❌ GitHub token not found. Set GITHUB_TOKEN, GITHUB_ACCESS_TOKEN, or GITHUB_PAT.", file=sys.stderr)
56+
sys.exit(1)
57+
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{issue_number}/comments"
58+
headers = {
59+
"Authorization": f"Bearer {token}",
60+
"Accept": "application/vnd.github+json",
61+
"X-GitHub-Api-Version": "2022-11-28",
62+
}
63+
response = requests.post(url, headers=headers, json={"body": body})
64+
response.raise_for_status()
65+
result = response.json()
66+
print(f"✅ Comment posted on issue #{issue_number}: {result['html_url']}")
67+
68+
# Fill in owner, repo, issue_number, and body before running:
69+
add_issue_comment("<owner>", "<repo>", <issue_number>, "<comment_body>")
70+
```
4471

4572
## Step 2: Label the Issue
4673

.github/skills/label-issue/SKILL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Fetch `.github/llms.md` from the target repository using GitHub MCP tools. The f
3535

3636
For template format, see [references/label_instructions_template.md](references/label_instructions_template.md).
3737

38-
If `.github/label-instructions.md` is not found:
38+
If `.github/llms.md` is not found:
3939
1. Fetch the list of labels defined in the target repository using `github/list_labels`
4040
2. Create a brief summary of available labels based on their names and descriptions
4141
3. Use the summary to determine which labels best match the issue content
@@ -103,8 +103,8 @@ Report the labeling decision with:
103103

104104
The skill requires:
105105

106-
1. **GITHUB_ACCESS_TOKEN** or **GITHUB_PAT** environment variable with `repo` scope
107-
2. **label-instructions.md** in target repository (optional but recommended)
106+
1. **GITHUB_ACCESS_TOKEN** or **GITHUB_TOKEN** environment variable with `repo` scope
107+
2. **.github/llms.md** in target repository (optional but recommended)
108108

109109
## Fallback Behavior
110110

.github/skills/label-issue/scripts/label_issue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
def get_github_token() -> str:
1919
"""Get GitHub token from environment variables."""
20-
token = os.environ.get("GITHUB_ACCESS_TOKEN") or os.environ.get("GITHUB_PAT")
20+
token = os.environ.get("GITHUB_ACCESS_TOKEN") or os.environ.get("GITHUB_TOKEN") or os.environ.get("GITHUB_PAT")
2121
if not token:
2222
raise ValueError(
23-
"GitHub token not found. Set GITHUB_ACCESS_TOKEN or GITHUB_PAT environment variable."
23+
"GitHub token not found. Set GITHUB_ACCESS_TOKEN, GITHUB_TOKEN, or GITHUB_PAT environment variable."
2424
)
2525
return token
2626

.github/workflows/issueLens-run.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5555
JAVATOOLING_INDEX_URL: ${{ secrets.JAVATOOLING_INDEX_URL }}
5656
MAILING_URL: ${{ secrets.MAILING_URL }}
57+
REPORT_RECIPIENTS: ${{ secrets.REPORT_RECIPIENTS }}
5758

5859
- name: Upload triage output
5960
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)