-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from pixeleye-io/test
Update compare.tsx
- Loading branch information
Showing
3 changed files
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@pixeleye/cli-env": minor | ||
--- | ||
|
||
Reading github action payload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CiEnv> { | ||
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, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters