Skip to content

Commit

Permalink
enhance: github: add tool to get job logs
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville committed Mar 4, 2025
1 parent d9a1866 commit 90f08cc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
addIssueLabels,
removeIssueLabels,
getUser,
getJobLogs,
} from './src/tools.js';

if (process.argv.length !== 3) {
Expand Down Expand Up @@ -99,6 +100,9 @@ try {
case 'removeIssueLabels':
await removeIssueLabels(octokit, process.env.OWNER, process.env.REPO, process.env.ISSUENUMBER, process.env.LABELS);
break;
case 'getJobLogs':
await getJobLogs(octokit, process.env.OWNER, process.env.REPO, process.env.JOBID);
break;
default:
throw new Error(`Unknown command: ${command}`);
}
Expand Down
9 changes: 9 additions & 0 deletions github/src/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,12 @@ export async function removeIssueLabels(octokit, owner, repo, issueNumber, label
export async function getUser(octokit) {
await octokit.users.getAuthenticated();
}

export async function getJobLogs(octokit, owner, repo, jobId) {
const response = await octokit.request('GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs', {
owner,
repo,
job_id: jobId
});
console.log(response.data);
}
13 changes: 12 additions & 1 deletion github/tool.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Name: GitHub
Description: Tools for interacting with GitHub
Metadata: bundle: true
Share Tools: Search Issues and PRs, Get Issue, Create Issue, Modify Issue, Close Issue, List Issue Comments, Add Comment to Issue, Get PR, Create PR, Modify PR, Close PR, List PR Comments, Add Comment to PR, List Repos, Get Star Count, List Assigned Issues, List PRs for Review, Add Issue Labels, Remove Issue Labels
Share Tools: Search Issues and PRs, Get Issue, Create Issue, Modify Issue, Close Issue, List Issue Comments, Add Comment to Issue, Get PR, Create PR, Modify PR, Close PR, List PR Comments, Add Comment to PR, List Repos, Get Star Count, List Assigned Issues, List PRs for Review, Add Issue Labels, Remove Issue Labels, Get Job Logs

---
Name: Search Issues and PRs
Expand Down Expand Up @@ -240,6 +240,17 @@ Param: labels: (optional) comma-separated list of labels to remove. If not provi

#!/usr/bin/env node ${GPTSCRIPT_TOOL_DIR}/index.js removeIssueLabels

---
Name: Get Job Logs
Description: Get the logs for a specific GitHub Actions job
Credential: ./credential
Share Context: GitHub Context
Param: owner: the owner of the repository
Param: repo: the name of the repository
Param: jobId: the ID of the job to get logs for

#!/usr/bin/env node ${GPTSCRIPT_TOOL_DIR}/index.js getJobLogs

---
Name: GitHub Context
Type: context
Expand Down

0 comments on commit 90f08cc

Please sign in to comment.