doughepi-yaml-env-action

0
README.md

yaml-env-action - A custom action for setting GitHub Workflow environment variables with YAML configuration files.

Introduction

yaml-env-action
is a custom JavaScript action that allows for the setting of GitHub Workflow environment variables with YAML configuration files. The action can take multiple YAML files input that override eachother, allowing for multi-environment configuration.


Features

  • Set GitHub Workflow environment variables using a list of YAML configuration files.
  • Pass multiple files to get environment overrides.
  • Complex YAML structures are supported.

Usage

With configuration file in the root directory of your project

And the following added to your GitHub Workflow

Access the newly exported environment variable in the following steps of your GitHub Workflow.

Another Example

A simple example...

With the following YAML configuration file.

Using the

yaml-env-action
allows you to reference the configured values as environment variables.

Environment Variable Names

Environment variables will be available in their flattened, capital-case form. For example, a YAML file like the following:

The following environment variables will be exported:

  • APP_PROJECT_ID
  • APP_NAME
  • APP_DNS
  • APP_DATABASE_HOSTNAME

Multiple Files

Multiple files can be passed to the

files
parameter of the action. This allows for various interesting use cases.

Note that the rightmost files override values in the leftmost files if their keys intersect.

Simple Composition

Multiple files can be passed to the

files
parameter to allow for multiple composed environment files to be available to the workflow.

Environment Overrides

Multiple files can be passed in a way that takes advantage of the rightmost-precedence to supply a set of base values and overriding environment values.

Given the following two configuration files.

Both can be refered to in the action.

You end up with the following environment variables.

  • NAME=application-dev
  • TERRAFORM_BUCKET=f46cc6e2-86e3-428d-b266-612d7913ef2d
  • WEB_SERVICE_DNS=my-d.webservice.com
  • API_SERVICE_DNS=my-d.apiservice.com

Contributing

All contributions are welcome. Create an issue for questions, bugs, and features. Feel free to submit pull requests, as well. The overall development process is detailed below.

Development Process

Create a development branch to make your changes within.

Get the

node_modules/

On your branch, you can make changes and push. The

test.yml
GitHub Workflow on this repository will kick off on each push, running simple unit and integration tests. Take a look at
test.yml
for more info on how this works. Feel free to add additional integration tests to verify your changes result in correct operation of the
yaml-env-action
.

You can also run the unit tests locally.

Before you create a pull request, you'll need to make sure the

dist/
folder is fully up to date with your changes.

Releases will be handled by @doughepi using tags and releases on the

main
branch.

— ⭐️ —

yaml-env-action is MIT licensed code. Designed & built in Minneapolis, MN. Used at General Mills.