name: tpl-file
description: "Format a Go template file given a yaml input file."
inputs:
  template:
    description: "Template or local path of the template file."
    required: true
  decoder:
    description: "Decoder format. Supported values: json, yaml, toml"
    required: true
    default: yaml
  input:
    description: "Input or local path of the input data file."
    required: true
  tmpDir:
    description: "Temporary directory. Default: _tmp"
    required: true
    default: _tmp
outputs:
  result:
    description: "Local path of the output file."
    value: ${{ steps.template.outputs.console }}
runs:
  using: "composite"
  steps:
  - name: "Make temporary file of template."
    id: mktmp-template
    uses: act/common/utils/mktemp@master
    with:
      input: ${{ inputs.template }}
      tmpDir: ${{ inputs.tmpDir }}
  - name: "Make temporary file of input."
    id: mktmp-input
    uses: act/common/utils/mktemp@master
    with:
      input: ${{ inputs.input }}
      tmpDir: ${{ inputs.tmpDir }}
  - name: "Generate template."
    id: template
    uses: act/common/tpl/tpl@master
    with:
      command: --file "${{ steps.mktmp-template.outputs.tmp }}" --decoder ${{ inputs.decoder }} < "${{ steps.mktmp-input.outputs.tmp }}"
  - name: "Remove temporary files."
    run: rm -rf "${{ inputs.tmpDir }}"
    shell: bash
    