name: "Get Run Info"
description: "Sanitizies and unifies the environment into run info"
inputs:
  service:
    description: "The service to work on"
    required: true
outputs:
  version:
    description: "Service version"
  build-number:
    description: "Build number"
runs:
  using: "composite"
  steps:
    - name: "Compute Service Version"
      shell: "bash"
      run: |
        set -x
        if [[ ! -z "${GITHUB_HEAD_REF}" || "${GITHUB_REF_NAME}" = "development" ]]; then
          VERSION="${GITHUB_SHA::8}"
          BUILD="${GITHUB_RUN_NUMBER}"
        else
          VERSION="v$(grep -Po '(?<=^version\s=\s")[^"]+' services/${{ inputs.service }}/pyproject.toml)"
          BUILD="01"
        fi
        echo "version=$VERSION" >> $GITHUB_OUTPUT
        echo "build-number=$BUILD" >> $GITHUB_OUTPUT
