name: Get available versions

on:
  workflow_dispatch:

jobs:
  get_available_versions:
    name: Get available versions
    runs-on: ubuntu-22.04
    outputs:
      version_options: ${{ steps.get_versions.outputs.version_options }}
    steps:
      - name: Get available versions from Docker Registry
        id: get_versions
        env:
          REGISTRY: hub.docker.com
          REPO: ${{ github.repository }}
        run: |
          REPO_NAME=$(echo $REPO | cut -d'/' -f2)

          TAGS=$(wget -q -O - "https://$REGISTRY/v2/namespaces/molvaapp/repositories/$REPO_NAME/tags?page_size=100" | jq -r '.results[].name')

          echo "===== Available versions: ====="
          echo "$TAGS"
          echo "==============================="