mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
2.2 KiB
2.2 KiB
name, agent, require_env_var
| name | agent | require_env_var | ||
|---|---|---|---|---|
| github | CodeActAgent |
|
How to Interact with Github
Environment Variable Available
GITHUB_TOKEN: A read-only token for Github.
Using GitHub's RESTful API
Use curl with the GITHUB_TOKEN to interact with GitHub's API. Here are some common operations:
Here's a template for API calls:
curl -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/{endpoint}"
First replace {endpoint} with the specific API path. Common operations:
-
View an issue or pull request:
- Issues:
/repos/{owner}/{repo}/issues/{issue_number} - Pull requests:
/repos/{owner}/{repo}/pulls/{pull_request_number}
- Issues:
-
List repository issues or pull requests:
- Issues:
/repos/{owner}/{repo}/issues - Pull requests:
/repos/{owner}/{repo}/pulls
- Issues:
-
Search issues or pull requests:
/search/issues?q=repo:{owner}/{repo}+is:{type}+{search_term}+state:{state}- Replace
{type}withissueorpr
-
List repository branches:
/repos/{owner}/{repo}/branches -
Get commit details:
/repos/{owner}/{repo}/commits/{commit_sha} -
Get repository details:
/repos/{owner}/{repo} -
Get user information:
/user -
Search repositories:
/search/repositories?q={query} -
Get rate limit status:
/rate_limit
Replace {owner}, {repo}, {commit_sha}, {issue_number}, {pull_request_number},
{search_term}, {state}, and {query} with appropriate values.
Important Notes
- Always use the GitHub API for operations instead of a web browser.
- The
GITHUB_TOKENis read-only. Avoid operations that require write access. - Git config (username and email) is pre-set. Do not modify.
- Edit and test code locally. Never push directly to remote.
- Verify correct branch before committing.
- Commit changes frequently.
- If the issue or task is ambiguous or lacks sufficient detail, always request clarification from the user before proceeding.
- You should avoid using command line tools like
sedfor file editing.