name: tpl-to-dir
description: "Format a Go template file given a yaml input file to a file of the same name in the specified output directory. The input yaml file environment variables replaced first."
inputs:
  templateFile:
    description: "Local path to the template file."
    required: true
  inputFilename:
    description: "Name of the input file without directories or extensions."
    required: true
  inputExtension:
    description: "Extension for the input file."
    required: false
    default: .yaml
  outputExtension:
    description: "Extension for the output file."
    required: false
  inputDirectory:
    description: "Directory for the input files."
    required: false
  outputDirectory:
    description: "Directory for the output files."
    required: false
outputs:
  outputFile:
    description: "The generated output file."
    value: ${{ inputs.outputDirectory }}/${{ inputs.inputFilename }}${{ inputs.outputExtension }}
runs:
  using: "composite"
  steps:
  - name: "Create Output Directory"
    run: mkdir ${{ inputs.outputDirectory }} -p
    shell: bash
  - name: "Generate Template"
    uses: act/common/tpl/tpl-env@master
    with:
      templateFile: ${{ inputs.inputDirectory }}/${{ inputs.templateFile }}
      inputFile: ${{ inputs.inputDirectory }}/${{ inputs.inputFilename }}${{ inputs.inputExtension }}
      outputFile: ${{ inputs.outputDirectory }}/${{ inputs.inputFilename }}${{ inputs.outputExtension }}