'Access environment variables from yaml in js (Git secret)
We are using a Zoom API in our React app and we want to use the Git and Heroku Secret to push and deploy our web application.
In our YAML file, we define the git as well as Heroku keys
jobs:
build:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # auto-generated
HEROKU_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }}
REACT_APP_ZOOM_KEY: ${{ secrets.ZOOM_API_KEY}}
REACT_APP_ZOOM_SECRET: ${{ secrets.ZOOM_API_SECRET }}
Now we want to access the Zoom Key and Secret in our config file to generate the signature (used for generating a Zoom meeting). We wanted to access them with process.env, like this:
sdkKey: isProduction()? process.env.ZOOM_Key : process.env.REACT_APP_ZOOM_KEY,
sdkSecret: isProduction()?process.env.ZOOM_Secret: process.env.REACT_APP_ZOOM_SECRET,
If I do this, I get the error, that my Zoom Key and secret are required and need to be strings.
I already tried to use JSON.stringify(process.env.REACT_APP_ZOOM_KEY) but I get the same error.
Maybe also important to mention, if I hardcode the key and secret directly in the config file, it is working, so I assume the error is with accessing the environment variable from the YAML file.
We would really appreciate it if someone could help us :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
