From b7d90555ef9b86f0b62bcd2fdf844bd9d941d073 Mon Sep 17 00:00:00 2001 From: Alfie Jones Date: Thu, 11 Apr 2024 17:25:09 +0100 Subject: [PATCH 1/2] Update compare.tsx --- libs/reviewer/src/compare.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/reviewer/src/compare.tsx b/libs/reviewer/src/compare.tsx index 86ee1593..467cfbee 100644 --- a/libs/reviewer/src/compare.tsx +++ b/libs/reviewer/src/compare.tsx @@ -49,7 +49,6 @@ const buttonHoverColors: Record = { unchanged: "", } - function ReviewDropdown({ snapshots, canReview, onReview }: { snapshots: DiffGroupedSnapshotTargetGroups; canReview: boolean; onReview: (status: Snapshot["status"]) => void }) { return ( From e2eb48793eaf6393ab2fc44b80697ed51f6fdcff Mon Sep 17 00:00:00 2001 From: Alfie Jones Date: Thu, 11 Apr 2024 17:48:01 +0100 Subject: [PATCH 2/2] reading github action payload --- .changeset/strong-spoons-smash.md | 5 ++++ .../cli/cli-env/src/services/github.ts | 23 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 .changeset/strong-spoons-smash.md diff --git a/.changeset/strong-spoons-smash.md b/.changeset/strong-spoons-smash.md new file mode 100644 index 00000000..fd0d98c7 --- /dev/null +++ b/.changeset/strong-spoons-smash.md @@ -0,0 +1,5 @@ +--- +"@pixeleye/cli-env": minor +--- + +Reading github action payload diff --git a/integrations/cli/cli-env/src/services/github.ts b/integrations/cli/cli-env/src/services/github.ts index a5561949..3b9aab76 100644 --- a/integrations/cli/cli-env/src/services/github.ts +++ b/integrations/cli/cli-env/src/services/github.ts @@ -1,13 +1,30 @@ /* eslint-disable turbo/no-undeclared-env-vars */ import { CiEnv } from "env-ci"; import { getCommit } from "../git"; +import { existsSync, readFileSync } from "fs"; + +interface GithubPayload { + pull_request?: { + head: { + sha: string; + ref: string; + }; + number: number; + }; +} export async function getGithubEnv(env: CiEnv): Promise { - const commitSha = await getCommit(); - console.log("SHA: ", commitSha); + let payload: GithubPayload = {}; + if ( + process.env.GITHUB_EVENT_PATH && + existsSync(process.env.GITHUB_EVENT_PATH) + ) { + payload = JSON.parse(readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")); + } + return { ...env, prBranch: process.env.GITHUB_HEAD_REF, - commit: commitSha || env.commit, + commit: payload.pull_request?.head.sha || env.commit, }; }