name: Extract ref from file

on:
  workflow_call:
    inputs:
      file:
        description: Path to the file to extract the ref from
        type: string
        required: false
    outputs:
      ref:
        description: "The extracted ref"
        value: ${{ jobs.extract-ref.outputs.ref }}

jobs:
  extract-ref:
    runs-on: ubuntu-24.04
    outputs:
      ref: ${{ steps.read.outputs.ref }}
    steps:
      - name: Check out repository
        uses: actions/checkout@v3
      - name: Extract ref from ${{ inputs.file }}
        id: read
        run: echo "ref=$(head -n 1 ${{ inputs.file }})" >> $GITHUB_OUTPUT
