Skip to content

Commit

Permalink
fix: enable the build information under Netlify environment
Browse files Browse the repository at this point in the history
  • Loading branch information
raichev-dima committed Sep 5, 2024
1 parent a003dfc commit 56efd30
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/docs/modules/banner/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ import { resolve } from 'pathe'
import packageJson from '../../../ui/package.json'

// This is an in-place way to figure out commit hash,
// but as we use railway, we have to use their variables.
// but as we use Netlify, we have to use their variables.
// import { execSync } from 'child_process'
// const getLastCommitHash = () => {
// return execSync('git rev-parse HEAD').toString().trim()
// }

// Netlify has several Git metadata read-only variables: COMMIT_REF, BRANCH, etc.
// see https://docs.netlify.com/configure-builds/environment-variables/#git-metadata for more details

/** Module used to add current file path to page-config */
export default defineNuxtModule<any>({
meta: {
Expand All @@ -20,9 +23,9 @@ export default defineNuxtModule<any>({
exclude: './page-config/**/*.{.vue,.md}',
},

setup(options) {
if (!process.env.RAILWAY_GIT_COMMIT_SHA) {
console.warn("Banner module is disabled because RAILWAY_GIT_COMMIT_SHA is not present in .env")
setup() {
if (!process.env.COMMIT_REF) {
console.warn('Banner module is disabled because COMMIT_REF is not present in .env')
return
}

Expand All @@ -32,8 +35,8 @@ export default defineNuxtModule<any>({
options: {
VERSION: packageJson.version,
DATE: new Date().toLocaleString(),
COMMIT: process.env.RAILWAY_GIT_COMMIT_SHA.slice(0,7), // same as github commit shortcut
BRANCH: process.env.RAILWAY_GIT_BRANCH,
COMMIT: process.env.COMMIT_REF.slice(0,7), // same as GitHub commit shortcut
BRANCH: process.env.BRANCH,
}
})
}
Expand Down

0 comments on commit 56efd30

Please sign in to comment.