Skip to content

Commit

Permalink
taking off the training wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
leopic committed Aug 12, 2024
1 parent d06c692 commit bb5bc76
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions .github/actions/time-to-first-review/src/fetch-reviews.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
const axios = require("axios");
// const axios = require("axios");
const github = require("@actions/github");

// Fetch reviews for a specific PR
module.exports = async (repo, token, prNumber) => {
try {
const octokit = github.getOctokit(token);

const out = await octokit.rest.pulls.listReviews({
const { data } = await octokit.rest.pulls.listReviews({
owner: repo.split("/")[0],
repo: repo.split("/")[1],
pull_number: prNumber,
});

const response = await axios.get(
`https://api.github.com/repos/${repo}/pulls/${prNumber}/reviews`,
{
headers: { Authorization: `token ${token}` },
}
);
// const response = await axios.get(
// `https://api.github.com/repos/${repo}/pulls/${prNumber}/reviews`,
// {
// headers: { Authorization: `token ${token}` },
// }
// );

console.log(" - - - ");
console.log(out);
console.log(response.data);
console.log(" - - - ");
// console.log(" - - - ");
// console.log(data);
// console.log(response.data);
// console.log(" - - - ");

return response.data;
// return response.data;
return data;
} catch (error) {
console.error(`Error fetching reviews for PR #${prNumber}:`, error.message);
return [];
Expand Down

0 comments on commit bb5bc76

Please sign in to comment.