T3 env lint error on Github CI

Run npm run lint
[email protected] lint next lint
❌ Invalid environment variables: { PUSHER_APP_ID: [ 'Required' ], PUSHER_SECRET: [ 'Required' ], CONTENTFUL_SPACE_ID: [ 'Required' ], CONTENTFUL_ACCESS_TOKEN: [ 'Required' ], NEXT_PUBLIC_PUSHER_KEY: [ 'Required' ] } error - Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error file:///home/runner/work/chirp/chirp/src/env.mjs:68 throw new Error("Invalid environment variables") ^ Error: Invalid environment variables at file:///home/runner/work/chirp/chirp/src/env.mjs:68:11 at ModuleJob.run (node:internal/modules/esm/module_job:194:25) Node.js v18.16.0 Error: Process completed with exit code 1. Problem is when I run lint locally I get no errors. This error only shows up on github CI. App deploys on Vercel just fine, it's only the Github CI. And here is my env.mjs also:
const server = z.object({
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),

PUSHER_APP_ID: z.string().min(1),
PUSHER_SECRET: z.string().min(1),
CONTENTFUL_SPACE_ID: z.string().min(1),
CONTENTFUL_ACCESS_TOKEN: z.string().min(1),
})

const client = z.object({
NEXT_PUBLIC_PUSHER_KEY: z.string().min(1),
})

const processEnv = {
DATABASE_URL: process.env.DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
NEXT_PUBLIC_PUSHER_KEY: process.env.NEXT_PUBLIC_PUSHER_KEY,
PUSHER_APP_ID: process.env.PUSHER_APP_ID,
PUSHER_SECRET: process.env.PUSHER_SECRET,
CONTENTFUL_SPACE_ID: process.env.CONTENTFUL_SPACE_ID,
CONTENTFUL_ACCESS_TOKEN: process.env.CONTENTFUL_ACCESS_TOKEN,
}
const server = z.object({
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),

PUSHER_APP_ID: z.string().min(1),
PUSHER_SECRET: z.string().min(1),
CONTENTFUL_SPACE_ID: z.string().min(1),
CONTENTFUL_ACCESS_TOKEN: z.string().min(1),
})

const client = z.object({
NEXT_PUBLIC_PUSHER_KEY: z.string().min(1),
})

const processEnv = {
DATABASE_URL: process.env.DATABASE_URL,
NODE_ENV: process.env.NODE_ENV,
NEXT_PUBLIC_PUSHER_KEY: process.env.NEXT_PUBLIC_PUSHER_KEY,
PUSHER_APP_ID: process.env.PUSHER_APP_ID,
PUSHER_SECRET: process.env.PUSHER_SECRET,
CONTENTFUL_SPACE_ID: process.env.CONTENTFUL_SPACE_ID,
CONTENTFUL_ACCESS_TOKEN: process.env.CONTENTFUL_ACCESS_TOKEN,
}
4 Replies
BigLung
BigLung2y ago
Im having this issue as well even though I have specified the env vars in question. Very weird...
Neto
Neto2y ago
Env
Never build your apps with invalid environment variables again. Validate and transform your environment with the full power of Zod.
Neto
Neto2y ago
export const env = createEnv({
// ...
// Tell the library to skip validation if condition is true.
skipValidation: false, // SOMETHING SOMETHING IS CI
});
export const env = createEnv({
// ...
// Tell the library to skip validation if condition is true.
skipValidation: false, // SOMETHING SOMETHING IS CI
});
scatter
scatter12mo ago
just had this myself and found a much better solution was to copy my .env.example to .env on the ci side, then the vars get pulled in and validated
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@0609f0983b7a228f052f81ef4c3d6510cae254ad
with:
version: 7.5.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- run: cp .env.example .env # this right here - make sure it goes after checkout
- run: pnpm install
- run: pnpm lint
- run: pnpm build
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@0609f0983b7a228f052f81ef4c3d6510cae254ad
with:
version: 7.5.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- run: cp .env.example .env # this right here - make sure it goes after checkout
- run: pnpm install
- run: pnpm lint
- run: pnpm build
Want results from more Discord servers?
Add your server