@@ -7,6 +7,7 @@ import process from 'process';
77
88// Determine if we are running on Cloudflare Pages
99const isCloudflare = process . env . CF_PAGES === '1' ;
10+ const isGithubActions = process . env . GITHUB_ACTIONS === 'true' ;
1011
1112// Use the appropriate adapter
1213const adapter = isCloudflare ? adapterCloudflare : adapterNode ;
@@ -15,11 +16,27 @@ function readEnv(path) {
1516 return dotenv . config ( { path } ) ?. parsed ?? { } ;
1617}
1718
19+ function getGitHash ( ) {
20+ if ( isGithubActions ) return process . env . GITHUB_SHA ;
21+ if ( isCloudflare ) return process . env . CF_COMMIT_SHA ;
22+
23+ return child_process . execSync ( 'git rev-parse HEAD' ) . toString ( ) . trim ( ) ;
24+ }
25+ function getGitBranch ( ) {
26+ if ( isGithubActions ) return process . env . GITHUB_REF_NAME ;
27+ if ( isCloudflare ) return process . env . CF_BRANCH ;
28+
29+ return child_process . execSync ( 'git rev-parse --abbrev-ref HEAD' ) . toString ( ) . trim ( ) ;
30+ }
31+
1832// Read environment variables from .env files
1933readEnv ( '.env.local' ) ;
2034readEnv ( `.env.${ process . env . NODE_ENV } ` ) ;
2135readEnv ( '.env' ) ;
2236
37+ const commitHash = getGitHash ( ) ;
38+ const branchName = getGitBranch ( ) ;
39+
2340/** @type {import('@sveltejs/kit').Config } */
2441const config = {
2542 extensions : [ '.svelte' ] ,
@@ -68,7 +85,7 @@ const config = {
6885 } ,
6986 } ,
7087 version : {
71- name : process . env . GIT_HASH ?? child_process . execSync ( 'git rev-parse HEAD' ) . toString ( ) . trim ( ) ,
88+ name : commitHash ,
7289 } ,
7390 } ,
7491} ;
0 commit comments