Skip to content

Custom github action used to read yaml files, supporting multiple keys and variable replacements

Notifications You must be signed in to change notification settings

nichmor/minimal-read-yaml

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal YAML Reader: A GitHub Action πŸ“

This action reads a .yaml file and sets one output for every key it contains. It aims to be minimal and simple.

Why? πŸ€”

Present solutions often do more than one thing (and do them well), but they are not intuitive to set up or use. Some have unresolved issues, and others don't work on Windows.

minimal-yaml-read is designed to be very simple to use and do only one thing: read a YAML file.

Credits: pietrobolcato/action-read-yaml, which served as the base for this GitHub Action.

Configuration Keys πŸ”§

There is one mandatory configuration key: config.

config

This key specifies the path to the YAML file that the action should read. It is required.

Example Usage πŸ“„

Let's use a simple example that contains some nested values:

Copy code
name: example
environment:
  name: example
  permissions:
    - name: example
      permission: read
    - name: example2
      permission: write

To access a plain key, use:

echo ${{ steps.read-yaml.outputs['name'] }}

To access a nested key, use:

echo ${{ steps.read-yaml.outputs['environment.name'] }}

Full Example Workflow πŸ› οΈ

Here is a complete example of a GitHub Actions workflow using the minimal-yaml-read action:

name: Example Workflow

on: [push]

jobs:
  read-yaml-job:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v2

      - name: Read YAML
        uses: nichmor/minimal-read-yaml@v0.0.2
        with:
          config: path/to/your/config.yaml

      - name: Access Output
        run: echo ${{ steps.read-yaml.outputs['environment.name'] }}

In this example, the minimal-yaml-read action reads the specified YAML file and sets outputs for each key. You can then access these outputs in subsequent steps using the ${{ steps.read-yaml.outputs['key'] }} syntax.

About

Custom github action used to read yaml files, supporting multiple keys and variable replacements

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%