feat: Allow skipping MAIL_HOST environment variable validation during build processes using SKIP_RUNTIME_ENV_VALIDATION.
Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 8s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m35s
Build & Deploy KLZ Cables / 🏗️ Build Gatekeeper (push) Successful in 20s
Build & Deploy KLZ Cables / 🏗️ Build App (push) Failing after 5m36s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Has been skipped
Build & Deploy KLZ Cables / ⚡ PageSpeed (push) Has been skipped
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 2s
Some checks failed
Build & Deploy KLZ Cables / 🔍 Prepare Environment (push) Successful in 8s
Build & Deploy KLZ Cables / 🧪 Quality Assurance (push) Successful in 1m35s
Build & Deploy KLZ Cables / 🏗️ Build Gatekeeper (push) Successful in 20s
Build & Deploy KLZ Cables / 🏗️ Build App (push) Failing after 5m36s
Build & Deploy KLZ Cables / 🚀 Deploy (push) Has been skipped
Build & Deploy KLZ Cables / ⚡ PageSpeed (push) Has been skipped
Build & Deploy KLZ Cables / 🔔 Notifications (push) Successful in 2s
This commit is contained in:
@@ -37,7 +37,7 @@ ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET
|
|||||||
ENV DIRECTUS_URL=$DIRECTUS_URL
|
ENV DIRECTUS_URL=$DIRECTUS_URL
|
||||||
|
|
||||||
# Validate environment variables during build
|
# Validate environment variables during build
|
||||||
RUN npx tsx scripts/validate-env.ts
|
RUN SKIP_RUNTIME_ENV_VALIDATION=true npx tsx scripts/validate-env.ts
|
||||||
|
|
||||||
RUN --mount=type=cache,target=/app/.next/cache npm run build
|
RUN --mount=type=cache,target=/app/.next/cache npm run build
|
||||||
|
|
||||||
|
|||||||
@@ -57,4 +57,14 @@ describe('envSchema', () => {
|
|||||||
});
|
});
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should skip MAIL_HOST requirement if SKIP_RUNTIME_ENV_VALIDATION is true', () => {
|
||||||
|
process.env.SKIP_RUNTIME_ENV_VALIDATION = 'true';
|
||||||
|
const result = envSchema.safeParse({
|
||||||
|
NEXT_PUBLIC_BASE_URL: 'https://example.com',
|
||||||
|
TARGET: 'production',
|
||||||
|
});
|
||||||
|
expect(result.success).toBe(true);
|
||||||
|
delete process.env.SKIP_RUNTIME_ENV_VALIDATION;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -57,8 +57,9 @@ export const envSchema = z
|
|||||||
.superRefine((data, ctx) => {
|
.superRefine((data, ctx) => {
|
||||||
const target = data.NEXT_PUBLIC_TARGET || data.TARGET;
|
const target = data.NEXT_PUBLIC_TARGET || data.TARGET;
|
||||||
const isDev = target === 'development' || !target;
|
const isDev = target === 'development' || !target;
|
||||||
|
const isBuildTimeValidation = process.env.SKIP_RUNTIME_ENV_VALIDATION === 'true';
|
||||||
|
|
||||||
if (!isDev && !data.MAIL_HOST) {
|
if (!isDev && !isBuildTimeValidation && !data.MAIL_HOST) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: 'MAIL_HOST is required in non-development environments',
|
message: 'MAIL_HOST is required in non-development environments',
|
||||||
|
|||||||
Reference in New Issue
Block a user