fix: use netlify git env vars (#727)
* fix: use netlify git env vars * fix: make git info vars optional in env * fix: remove git info parsing, and use netlify only * fix: handle missing git repo url * fix: format
This commit is contained in:
parent
76386a2a57
commit
80dee1e03d
@ -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
|
||||
|
@ -43,12 +43,16 @@ export const NetworkInfo = () => {
|
||||
</Lozenge>
|
||||
.{' '}
|
||||
</p>
|
||||
{GIT_COMMIT_HASH && GIT_ORIGIN_URL && (
|
||||
{GIT_COMMIT_HASH && (
|
||||
<p className="mb-[1rem]">
|
||||
{t('Version/commit hash')}:{' '}
|
||||
<Link
|
||||
href={`${GIT_ORIGIN_URL}/commit/${GIT_COMMIT_HASH}`}
|
||||
target="_blank"
|
||||
href={
|
||||
GIT_ORIGIN_URL
|
||||
? `${GIT_ORIGIN_URL}/commit/${GIT_COMMIT_HASH}`
|
||||
: undefined
|
||||
}
|
||||
target={GIT_ORIGIN_URL ? '_blank' : undefined}
|
||||
>
|
||||
{GIT_COMMIT_HASH}
|
||||
</Link>
|
||||
|
@ -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<string, string>,
|
||||
|
Loading…
Reference in New Issue
Block a user