mirror of
https://github.com/freeedcom/ai-codereviewer.git
synced 2024-11-23 12:39:02 +00:00
try to use event data instead
This commit is contained in:
parent
29cd406230
commit
6454621f44
19
dist/index.js
vendored
19
dist/index.js
vendored
@ -197,24 +197,23 @@ function createReviewComment(owner, repo, pull_number, comments) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
function main() {
|
function main() {
|
||||||
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const prDetails = yield getPRDetails();
|
const prDetails = yield getPRDetails();
|
||||||
let diff;
|
let diff;
|
||||||
console.log("Running the action...");
|
console.log("Running the action...");
|
||||||
console.log("Event name:", process.env.GITHUB_EVENT_NAME);
|
const eventData = JSON.parse((0, fs_1.readFileSync)((_a = process.env.GITHUB_EVENT_PATH) !== null && _a !== void 0 ? _a : "", "utf8"));
|
||||||
console.log("PR event path:");
|
console.log("Event data:");
|
||||||
console.log(process.env.GITHUB_EVENT_PATH);
|
console.log(eventData);
|
||||||
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
|
if (eventData.action === "opened") {
|
||||||
console.log("Pull request event");
|
console.log("Pull request event");
|
||||||
diff = yield getDiff(prDetails.owner, prDetails.repo, prDetails.pull_number);
|
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");
|
console.log("Push event");
|
||||||
const pushEvent = JSON.parse((0, fs_1.readFileSync)(process.env.GITHUB_EVENT_PATH || "", "utf8"));
|
console.log(eventData);
|
||||||
console.log("Push event:");
|
const newBaseSha = eventData.before;
|
||||||
console.log(pushEvent);
|
const newHeadSha = eventData.after;
|
||||||
const newBaseSha = pushEvent.before;
|
|
||||||
const newHeadSha = pushEvent.after;
|
|
||||||
const response = yield octokit.repos.compareCommits({
|
const response = yield octokit.repos.compareCommits({
|
||||||
owner: prDetails.owner,
|
owner: prDetails.owner,
|
||||||
repo: prDetails.repo,
|
repo: prDetails.repo,
|
||||||
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
22
src/main.ts
22
src/main.ts
@ -197,25 +197,23 @@ async function main() {
|
|||||||
const prDetails = await getPRDetails();
|
const prDetails = await getPRDetails();
|
||||||
let diff: string | null;
|
let diff: string | null;
|
||||||
console.log("Running the action...");
|
console.log("Running the action...");
|
||||||
console.log("Event name:", process.env.GITHUB_EVENT_NAME);
|
const eventData = JSON.parse(
|
||||||
console.log("PR event path:");
|
readFileSync(process.env.GITHUB_EVENT_PATH ?? "", "utf8")
|
||||||
console.log(process.env.GITHUB_EVENT_PATH);
|
);
|
||||||
if (process.env.GITHUB_EVENT_NAME === "pull_request") {
|
console.log("Event data:");
|
||||||
|
console.log(eventData);
|
||||||
|
if (eventData.action === "opened") {
|
||||||
console.log("Pull request event");
|
console.log("Pull request event");
|
||||||
diff = await getDiff(
|
diff = await getDiff(
|
||||||
prDetails.owner,
|
prDetails.owner,
|
||||||
prDetails.repo,
|
prDetails.repo,
|
||||||
prDetails.pull_number
|
prDetails.pull_number
|
||||||
);
|
);
|
||||||
} else if (process.env.GITHUB_EVENT_NAME === "push") {
|
} else if (eventData.action === "synchronize") {
|
||||||
console.log("Push event");
|
console.log("Push event");
|
||||||
const pushEvent = JSON.parse(
|
console.log(eventData);
|
||||||
readFileSync(process.env.GITHUB_EVENT_PATH || "", "utf8")
|
const newBaseSha = eventData.before;
|
||||||
);
|
const newHeadSha = eventData.after;
|
||||||
console.log("Push event:");
|
|
||||||
console.log(pushEvent);
|
|
||||||
const newBaseSha = pushEvent.before;
|
|
||||||
const newHeadSha = pushEvent.after;
|
|
||||||
|
|
||||||
const response = await octokit.repos.compareCommits({
|
const response = await octokit.repos.compareCommits({
|
||||||
owner: prDetails.owner,
|
owner: prDetails.owner,
|
||||||
|
Loading…
Reference in New Issue
Block a user