t3-oss / t3-env

https://env.t3.gg
MIT License
2.45k stars 79 forks source link

T3-env can't find environment variables on github action? #221

Closed rikhall1515 closed 2 months ago

rikhall1515 commented 2 months ago

Description

T3-Env works perfectly on dev and prod but not on github actions. For context, my next.config.mjs file is configured with jiti as per the documentation.

Here is a link where you can see the output. Here is the image for a quick preview: screen-11 39 14 20 04 2024

Here you can see the environment variables in the workflow file.

Here below you can see that the repository has the correct environment variables set that are affected: screen-11 34 44 20 04 2024

Here is the configuration of env/client.ts that is associated with the error output:

import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
  isServer: typeof window === "undefined",
  client: {
    NEXT_PUBLIC_BASE_URL: z.string().url(),
    NEXT_PUBLIC_SITE_NAME: z.string(),
  },
  runtimeEnv: {
    NEXT_PUBLIC_BASE_URL: process.env.NEXT_PUBLIC_BASE_URL,
    NEXT_PUBLIC_SITE_NAME: process.env.NEXT_PUBLIC_SITE_NAME,
  },
});

Question

What's the easiest way of dealing with this that also maintains good security practices for environment variables?

Edit

Found out how to fix it, just use repo secrets instead.