Skip to content

Commit 56efd30

Browse files
committed
fix: enable the build information under Netlify environment
1 parent a003dfc commit 56efd30

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/docs/modules/banner/module.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import { resolve } from 'pathe'
33
import packageJson from '../../../ui/package.json'
44

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

12+
// Netlify has several Git metadata read-only variables: COMMIT_REF, BRANCH, etc.
13+
// see https://docs.netlify.com/configure-builds/environment-variables/#git-metadata for more details
14+
1215
/** Module used to add current file path to page-config */
1316
export default defineNuxtModule<any>({
1417
meta: {
@@ -20,9 +23,9 @@ export default defineNuxtModule<any>({
2023
exclude: './page-config/**/*.{.vue,.md}',
2124
},
2225

23-
setup(options) {
24-
if (!process.env.RAILWAY_GIT_COMMIT_SHA) {
25-
console.warn("Banner module is disabled because RAILWAY_GIT_COMMIT_SHA is not present in .env")
26+
setup() {
27+
if (!process.env.COMMIT_REF) {
28+
console.warn('Banner module is disabled because COMMIT_REF is not present in .env')
2629
return
2730
}
2831

@@ -32,8 +35,8 @@ export default defineNuxtModule<any>({
3235
options: {
3336
VERSION: packageJson.version,
3437
DATE: new Date().toLocaleString(),
35-
COMMIT: process.env.RAILWAY_GIT_COMMIT_SHA.slice(0,7), // same as github commit shortcut
36-
BRANCH: process.env.RAILWAY_GIT_BRANCH,
38+
COMMIT: process.env.COMMIT_REF.slice(0,7), // same as GitHub commit shortcut
39+
BRANCH: process.env.BRANCH,
3740
}
3841
})
3942
}

0 commit comments

Comments
 (0)