name: envsubst
description: "Substitute environment variables in the given input."
inputs:
  input:
    description: "Input to substitute."
    required: false
  tmpDir:
    description: "Temporary directory. Default: _tmp"
    required: true
    default: _tmp
outputs:
  result:
    description: "The result of the substitution."
    value: ${{ steps.envsubst.outputs.console }}
runs:
  using: "composite"
  steps:
  - name: "Make temporary file of input."
    id: mktmp
    uses: act/common/utils/mktemp@master
    with:
      input: ${{ inputs.input }}
      tmpDir: ${{ inputs.tmpDir }}
  - name: "Download file."
    id: envsubst
    uses: act/common/distros/rockylinux@master
    with:
      args: envsubst < ${{ steps.mktmp.outputs.tmp }}
  - name: "Remove temporary files."
    run: rm -rf "${{ inputs.tmpDir }}"
    shell: bash