Skip to content

Create .env file based on Github Secrets

Actions
Github Action to write Github Secrets into a .env file
v2.0.0
Latest
Star (40)

create-env-file action

Github Action to write Github Secrets into a .env file. The action looks for variables that start with INPUT_ENV_ and creates a .env file with them.

Inputs

key

Required Should start with ENV_ prefix

value

Required Should be in the format specified in Github's documentation

file-name

Optional The name of the file to be written. Default .env

Usage

  1. Add it as a new step to your job.
  2. Add a key/value in with: section.
  3. Go to your repository -> settings -> secrets and add secrets you want to be written into a .env file.

Example usage v2

on:
  push:
    branches:
      - master
jobs: 
  create_env_file_job:
    runs-on: ubuntu-latest
    steps:
      - name: Create .env file
        uses: ozaytsev86/create-env-file@v2.0.0
        with:
          ENV_TEST_API_KEY: ${{ secrets.TEST_API_KEY }}
          ENV_ANOTHER_KEY: ${{ secrets.ANOTHER_KEY }}

In case you want to use an old version of the action, you can use the following example.

Example usage v1

on:
  push:
    branches:
      - master
jobs: 
  create_env_file_job:
    runs-on: ubuntu-latest
    steps:
      - name: Create .env file
        uses: ozaytsev86/create-env-file@v1
        with:
          ENV_TEST_API_KEY: ${{ secrets.TEST_API_KEY }}
          ENV_ANOTHER_KEY: ${{ secrets.ANOTHER_KEY }}

NOTE: be sure that ubuntu-latest or any other image you use has node installed.

Result .env

TEST_API_KEY=1234test
ANOTHER_KEY=Super secret

License

This project released under the MIT License.

Create .env file based on Github Secrets is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Github Action to write Github Secrets into a .env file
v2.0.0
Latest

Create .env file based on Github Secrets is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.