diff --git a/libs/environment/src/utils/validate-environment.ts b/libs/environment/src/utils/validate-environment.ts index 05979410e..58c25434b 100644 --- a/libs/environment/src/utils/validate-environment.ts +++ b/libs/environment/src/utils/validate-environment.ts @@ -23,9 +23,9 @@ const schemaObject = { ETHERSCAN_URL: z.string().url({ message: 'The NX_ETHERSCAN_URL environment variable must be a valid url', }), - GIT_BRANCH: z.string(), - GIT_COMMIT_HASH: z.string(), - GIT_ORIGIN_URL: z.string(), + GIT_BRANCH: z.optional(z.string()), + GIT_COMMIT_HASH: z.optional(z.string()), + GIT_ORIGIN_URL: z.optional(z.string()), GITHUB_FEEDBACK_URL: z.optional(z.string()), VEGA_ENV: z.nativeEnum(Networks), VEGA_NETWORKS: z diff --git a/libs/network-info/src/network-info.tsx b/libs/network-info/src/network-info.tsx index e7dfd1a46..b20577358 100644 --- a/libs/network-info/src/network-info.tsx +++ b/libs/network-info/src/network-info.tsx @@ -43,12 +43,16 @@ export const NetworkInfo = () => { .{' '}
- {GIT_COMMIT_HASH && GIT_ORIGIN_URL && ( + {GIT_COMMIT_HASH && (
{t('Version/commit hash')}:{' '}
{GIT_COMMIT_HASH}
diff --git a/tools/utils/setup-environment.ts b/tools/utils/setup-environment.ts
index d66f9140f..c82727a83 100644
--- a/tools/utils/setup-environment.ts
+++ b/tools/utils/setup-environment.ts
@@ -1,21 +1,12 @@
import * as fs from 'fs';
import * as path from 'path';
-import { execSync } from 'child_process';
import * as log from 'npmlog';
import * as dotenv from 'dotenv';
import type { ExecutorContext } from '@nrwl/devkit';
-process.env['NX_GIT_COMMIT_HASH'] = execSync('git rev-parse HEAD')
- .toString()
- .replace(/[\r\n]/gm, '');
-process.env['NX_GIT_BRANCH'] = execSync('git rev-parse --abbrev-ref HEAD')
- .toString()
- .replace(/[\r\n]/gm, '');
-process.env['NX_GIT_ORIGIN_URL'] = execSync('git remote get-url origin')
- .toString()
- .replace('ssh://git@', 'https://')
- .replace('.git', '')
- .replace(/[\r\n]/gm, '');
+process.env['NX_GIT_COMMIT_HASH'] = process.env['COMMIT_REF'] ?? 'dev';
+process.env['NX_GIT_BRANCH'] = process.env['BRANCH'] ?? 'dev';
+process.env['NX_GIT_ORIGIN_URL'] = process.env['REPOSITORY_URL'] ?? '';
const logEnvData = (
envMap: Record