0

How could my react native app access the CircleCI env vars because they are very sensitive and I cannot hard code them.

Hamza Hmem
  • 502
  • 5
  • 11

1 Answers1

0

We had some problem with this as well. I believe react-native-config reads an env file. We had to write a script to call in order to create and env file with the environment variables stored in CircleCI.

We used FS to create a env file and grabbed the values off process.env.CIRCLECI_EXAMPLE_VAR

import * as FS from 'fs';

const data = `KEY=${process.env.CIRCLECI_EXAMPLE_VAR}`;

fs.writeFileSync('./.env', data);

I think getting react-native-dotenv might be another solution as that allows us to extract these values from '@env' with a bit of set up.

  • 1
    Hi react-native-dotenv maintainer here. Yes, it requires a couple of Babel lines to setup, but then you can add your env secrets for CircleCI using the environment variables setup https://circleci.com/docs/env-vars/#private-keys-and-secrets I can't say the same for react-native-config – Kemal Ahmed Nov 29 '22 at 12:08