Skip to content

Commit

Permalink
chore: add netlify env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
w-gao committed Apr 4, 2023
1 parent 6f36f0e commit e7f8a25
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/web/src/ui/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function Footer() {
if (env) {
const build_date = env["BUILD_DATE"] || "N/a"
const branch = env["BRANCH"] || "dev"
const commit_ref = (env["GITHUB_WORKFLOW_SHA"] as string) || "N/a"
const commit_ref = (env["COMMIT_REF"] as string) || "N/a"
info = (
<>
Current build: {branch}@{commit_ref.slice(0, 7)} ({build_date}).
Expand Down
13 changes: 13 additions & 0 deletions scripts/postbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ data = JSON.stringify({
BUILD_DATE: date.toLocaleDateString("en-US", {dateStyle: "medium", timeZone: "America/Los_Angeles"}),
BUILD_TIME: date.toLocaleTimeString("en-US", {timeZone: "America/Los_Angeles"}),

BRANCH: process.env.GITHUB_REF_NAME || process.env.BRANCH,
COMMIT_REF: process.env.GITHUB_WORKFLOW_SHA || process.env.COMMIT_REF,

// GitHub Actions
GITHUB_WORKFLOW_SHA: process.env.GITHUB_WORKFLOW_SHA,
GITHUB_REF: process.env.GITHUB_REF,
Expand All @@ -28,6 +31,16 @@ data = JSON.stringify({
GITHUB_ACTOR: process.env.GITHUB_ACTOR,
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME,
GITHUB_RUN_ID: process.env.GITHUB_RUN_ID,

// Netlify
NETLIFY_BRANCH: process.env.BRANCH,
NETLIFY_URL: process.env.URL,
NETLIFY_COMMIT_REF: process.env.COMMIT_REF,
NETLIFY_HEAD: process.env.HEAD,
NETLIFY_CONTEXT: process.env.CONTEXT,
NETLIFY_BUILD_ID: process.env.BUILD_ID,
NETLIFY_PULL_REQUEST: process.env.PULL_REQUEST,
NETLIFY_DEPLOY_ID: process.env.DEPLOY_ID,
})

fs.writeFile(filename, data, function (err) {
Expand Down

0 comments on commit e7f8a25

Please sign in to comment.