This Github Action generates a local .env file in a github runner for react apps, by extracting environment variables from your secrets or custom defined object, that match the prefix "REACT_APP"
.env
file (or a prefix.env
if a ENV_FILE_NAME
was specified) in the current working directory of the runner. package.json
file, and moves the .env
file to it's same directory.Below is an example of the minimum appropriate configuration
name: Create Env
uses: aasmal97/create-react-app-env@2.0.0
with:
REACT_APP_SECRETS: ${{toJson(secrets)}}
REACT_APP_SECRETS
: Takes in a stringified JSON object that holds all your secrets or variables (required)ENV_FILE_NAME
: If you want to customized the .env name (i.e local.env
, etc), add the desired name here. (optional)DESTINATION_PATH
: The ABSOLUTE PATH, that you want the .env file to be generated in (optional)WORKING_DIRECTORY_PATH
: The ABSOLUTE PATH, that you want the action to start at (optional)
name: Create Env
uses: aasmal97/create-react-app-env@2.0.0
with:
REACT_APP_SECRETS: ${{toJson(secrets)}}
ENV_FILE_NAME: 'local'
DESTINATION_PATH: ${{ github.workspace }}/src
DESTINATION_PATH
value, so the location of the file being generated does not change and is always known. package.json
, and not specify an absolute destination path, try to ensure consistency by setting a WORKING_DIRECTORY_PATH
of the action as close as possible, to the package.json file. Below is an example of this: name: Create Env
uses: aasmal97/create-react-app-env@2.0.0
with:
WORKING_DIRECTORY_PATH: ${{ github.workspace }}/src
REACT_APP_SECRETS: ${{toJson(secrets)}}