---
name: Deploy Collection

# Trigger the workflow however you prefer
on:
 - push
#  release:
#    types:
#      - published

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Build and Deploy Collection
        uses: artis3n/ansible_galaxy_collection@v2
        with:
          api_key: '${{ secrets.GALAXY_API_KEY }}'

      - name: Get the version name from the tags
        run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
      
      - name: Injecting a dynamic Collection version
        uses: artis3n/ansible_galaxy_collection@v2
        with:
          api_key: '${{ secrets.GALAXY_API_KEY }}'
          galaxy_version: '${{ env.RELEASE_VERSION }}'
