aasmal97 / create-react-app-env

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"
https://github.com/marketplace/actions/create-react-app-env
2 stars 0 forks source link
build-tool create-react-app deployment environment-variables github-actions react secrets typescript utilities yaml

Create-React-App-Env

Description

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"

How this action works

  1. First, the action parses the secrets object, and filters out any secrets that do not match the REACT_APP prefix.
  2. After, the action creates a .env file (or a prefix.env if a ENV_FILE_NAME was specified) in the current working directory of the runner.
  3. Then, the action moves the generated file to the custom destination path provided by the user, OR recursively searches up from the current working directory, to find the NEAREST package.json file, and moves the .env file to it's same directory.
  4. Once the action confirms the move, the runner exits, and if no error is present, continues to the next step

How to Use:

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)}}

Inputs

name: Create Env
uses: aasmal97/create-react-app-env@2.0.0
with: 
  WORKING_DIRECTORY_PATH: ${{ github.workspace }}/src
  REACT_APP_SECRETS: ${{toJson(secrets)}}