try to use event data instead

This commit is contained in:
Ville Saukkonen 2023-04-22 18:02:46 +03:00
parent 29cd406230
commit 6454621f44
3 changed files with 20 additions and 23 deletions

19
dist/index.js vendored

@ -197,24 +197,23 @@ function createReviewComment(owner, repo, pull_number, comments) {
});
}
function main() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const prDetails = yield getPRDetails();
let diff;
console.log("Running the action...");
console.log("Event name:", process.env.GITHUB_EVENT_NAME);
console.log("PR event path:");
console.log(process.env.GITHUB_EVENT_PATH);
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
const eventData = JSON.parse((0, fs_1.readFileSync)((_a = process.env.GITHUB_EVENT_PATH) !== null && _a !== void 0 ? _a : "", "utf8"));
console.log("Event data:");
console.log(eventData);
if (eventData.action === "opened") {
console.log("Pull request event");
diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
}
else if (process.env.GITHUB_EVENT_NAME === "push") {
else if (eventData.action === "synchronize") {
console.log("Push event");
const pushEvent = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
console.log("Push event:");
console.log(pushEvent);
const newBaseSha = pushEvent.before;
const newHeadSha = pushEvent.after;
console.log(eventData);
const newBaseSha = eventData.before;
const newHeadSha = eventData.after;
const response = yield octokit.repos.compareCommits({
owner: prDetails.owner,
repo: prDetails.repo,

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

@ -197,25 +197,23 @@ async function main() {
const prDetails = await getPRDetails();
let diff: string | null;
console.log("Running the action...");
console.log("Event name:", process.env.GITHUB_EVENT_NAME);
console.log("PR event path:");
console.log(process.env.GITHUB_EVENT_PATH);
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
const eventData = JSON.parse(
readFileSync(process.env.GITHUB_EVENT_PATH ?? "", "utf8")
);
console.log("Event data:");
console.log(eventData);
if (eventData.action === "opened") {
console.log("Pull request event");
diff = await getDiff(
prDetails.owner,
prDetails.repo,
prDetails.pull_number
);
} else if (process.env.GITHUB_EVENT_NAME === "push") {
} else if (eventData.action === "synchronize") {
console.log("Push event");
const pushEvent = JSON.parse(
readFileSync(process.env.GITHUB_EVENT_PATH || "", "utf8")
);
console.log("Push event:");
console.log(pushEvent);
const newBaseSha = pushEvent.before;
const newHeadSha = pushEvent.after;
console.log(eventData);
const newBaseSha = eventData.before;
const newHeadSha = eventData.after;
const response = await octokit.repos.compareCommits({
owner: prDetails.owner,