name: shasum-files
description: "Output the shasum of files in a directory matching a pattern."
inputs:
  directory:
    description: "Directory to search."
    required: true
    default: '.'
  pattern:
    description: "Pattern of files to search for."
    required: true
    default: '*'
outputs:
  sums:
    description: "The sums of the files matching the pattern."
    value: ${{ steps.sums.outputs.sums }}
runs:
  using: "composite"
  steps:
  - name: "Get sums of files matching the pattern"
    id: sums
    run: |
      OUTPUT=$(bash ${{ github.action_path }}/get_sums.sh "${{ inputs.directory }}" "${{ inputs.pattern }}")
      if [[ -n "$OUTPUT" ]]; then
        echo "sums<<EOF" >> "$GITHUB_OUTPUT"
        echo "$OUTPUT" >> "$GITHUB_OUTPUT"
        echo "EOF" >> "$GITHUB_OUTPUT"
      fi
    shell: bash
