@@ -3,12 +3,15 @@ import { resolve } from 'pathe'
3
3
import packageJson from '../../../ui/package.json'
4
4
5
5
// 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.
7
7
// import { execSync } from 'child_process'
8
8
// const getLastCommitHash = () => {
9
9
// return execSync('git rev-parse HEAD').toString().trim()
10
10
// }
11
11
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
+
12
15
/** Module used to add current file path to page-config */
13
16
export default defineNuxtModule < any > ( {
14
17
meta : {
@@ -20,9 +23,9 @@ export default defineNuxtModule<any>({
20
23
exclude : './page-config/**/*.{.vue,.md}' ,
21
24
} ,
22
25
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' )
26
29
return
27
30
}
28
31
@@ -32,8 +35,8 @@ export default defineNuxtModule<any>({
32
35
options : {
33
36
VERSION : packageJson . version ,
34
37
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 ,
37
40
}
38
41
} )
39
42
}
0 commit comments