Skip to content

Commit

Permalink
Added octokit parser
Browse files Browse the repository at this point in the history
  • Loading branch information
nbhoski committed Jun 18, 2024
1 parent 0172f0d commit e47f313
Showing 1 changed file with 26 additions and 27 deletions.
53 changes: 26 additions & 27 deletions src/buildSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,38 +83,37 @@ export async function processAndDisplayBuildSummary() {
}

export function getWorkflowStepNames(repository: string) {
const [owner, repo] = repository.split('/');
console.log(owner);
console.log(repo);
const runId = process.env.GITHUB_RUN_ID
console.log(runId);
//const path = '.github/workflows/bat.yml';
//console.log(path);
getWorkflowRunJobs(owner as string, repo as string, runId as string);
const [owner, repo] = repository.split('/');
console.log(owner);
console.log(repo);
const runId = process.env.GITHUB_RUN_ID
console.log(runId);
const path = '.github/workflows/bat.yml';
console.log(path);
getWorkflowRunJobs(owner as string, repo as string, path as string);
}


export async function getWorkflowRunJobs(owner: string, repo: string, runID: string) {
export async function getWorkflowRunJobs(owner: string, repo: string, path: string) {
// Replace with your GitHub personal access token

const octokit = new Octokit({
auth: process.env.MY_GITHUB_TOKEN,
});
try {
const octokit = new Octokit({
auth: process.env.MY_GITHUB_TOKEN,
});
try {
// Fetch the jobs for the specified workflow run
const response = await octokit.actions.getWorkflowRun({
owner,
repo,
runID,
});

const contentEncoded = response.data.jobs;
//const contentDecoded = Buffer.from(contentEncoded, 'base64').toString('utf-8');
const response = await octokit.repos.getContent({
owner,
repo,
path,
});

const contentEncoded = response.data.content;
const contentDecoded = Buffer.from(contentEncoded, 'base64').toString('utf-8');
// Iterate over the jobs and log the step names
console.log(contentEncoded);

console.log(contentDecoded);
const jobs = response.data.jobs;

} catch (error) {
console.error(error);
}
} catch (error) {
console.error(error);
}
}

0 comments on commit e47f313

Please sign in to comment.