Skip to content
box

GitHub Action

Get YML Paths

v1.0.1 Latest version

Get YML Paths

box

Get YML Paths

A GitHub Action to access values of YAML files

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Get YML Paths

uses: CumulusDS/[email protected]

Learn more about this action in CumulusDS/get-yaml-paths-action

Choose a version

Get YAML Paths

This action reads a YAML file and outputs selected properties.

The action uses a JMESPath query to access properties at the provided paths. The file is the only input required. All other inputs are mapped into equally named outputs with the value at the given paths.

Inputs

file

Required The name of the file to load.

name: query

Give each path to look-up as a name: query input pair.

Outputs

The Action generates an output for name with the value at the corresponding path. Output names are all lowercase, due to limitations in GitHub Actions.

Example usage

Given an input file file.yml:

foo:
  bar: baz
provider:
  stage: green

A step definition like this:

uses: CumulusDS/[email protected]
with:
  file: file.yml
  bar: foo.bar
  providerStage: provider.stage

sets the bar output to baz and sets the providerstage output (note all lower-case) to green.

Object and array outputs are JSON-serialized. For example, given an input file qux.yml:

qux:
  - bar: hello
  - bar: world

A step definition like this:

uses: CumulusDS/[email protected]
with:
  file: qux.yml
  bars: qux[].bar

Sets the bars output to ["hello","world"].

CloudFormation

The CloudFormation YAML schema is supported. The input file can contain the CloudFormation template tags:

  • !And
  • !Base64
  • !Cidr
  • !Condition
  • !Equals
  • !FindInMap
  • !GetAtt
  • !GetAZs
  • !If
  • !ImportValue
  • !Join
  • !Not
  • !Or
  • !Ref
  • !Select
  • !Split
  • !Sub

Possible Issues

Quoting Special Characters

Keys with hyphens and other special characters should be quoted in the query. For example, given an input file like this:

foo-bar: baz

Then use a step definition like this:

uses: CumulusDS/[email protected]
with:
  file: file.yml
  foobar: '"foo-bar"'

The query should be "foo-bar" to get the value of the foo-bar key. Without the quotes, the query would be interpreted as a numerical subtraction, which would result in an error.

GitHub Runner Warning

The inputs to this action cannot be statically defined or listed in the actions.yml definition. This results in a nuisance warning from the Actions Runner like this:

Warning: Unexpected input(s) '...', valid inputs are ['file']

The actions/runner#514 issue tracks this limitation of the Actions Runner.

See Also

get-json-paths-action

Development

License

This package is MIT licensed.