obytes / react-native-template-obytes

📱 A template for your next React Native project: Expo, PNPM, TypeScript, TailwindCSS, Husky, EAS, GitHub Actions, Env Vars, expo-router, react-query, react-hook-form.
https://starter.obytes.com
MIT License
2.11k stars 314 forks source link

How to handle ENV variables for CI? #336

Closed BlvckParrot closed 1 week ago

BlvckParrot commented 2 months ago

How do you handle ENV variables for CI runs, without having any .env file in remote repository?

yjose commented 1 month ago

You just need to add them as global environment variables in your repository, and the script should read them from the system. please try it and let me know in case it's not working as expected

heyanurag commented 1 month ago

@yjose

I just read this guide - https://starter.obytes.com/ci-cd/app-releasing-process/

It says for a QA release I have to run prebuild:staging and then build:staging:__ commands. (Similar flow for production).

It further says:

The above commands will generate the required credentials for the build and store them in EAS servers so that we can use them later to trigger the build from GitHub actions.

Does this mean that for every QA/production release I have to run the build locally -- So that the env variables for a particular environment are updated on the eas servers?

I understand that clientEnv is being added to app.config.ts as follows but how is this made available to the eas servers for different environments?

extra: {
    ...ClientEnv,
    eas: {
      projectId: Env.EAS_PROJECT_ID,
    },
  },

How does eas handle env variables for different environments? I am a little confused with the release flow.

Thank you for this amazing starter! Its a life saver 💟

yjose commented 1 month ago

@heyanurag glad you found the starter useful.

only singing credentials will be added automatically. For other env variables, you should add them manually

SamuelLHuber commented 1 month ago

is it intended that npx create-obytes-app@latest MyApp does not include the .env files in the .gitignore ? I'd assume for security reasons to not check secrets into the repo it would be best practice to include any .env in the .gitignore

Is this handeled by the precommit hooks?

yjose commented 1 week ago

@SamuelLHuber @heyanurag, just added an new section in the docs for more clarity regarding env files and github action https://starter.obytes.com/ci-cd/app-releasing-process/#github-action-and-env-variables