name: CD

on:
  release:
    types: [published]

jobs:
  dispatchSchema:
    name: "Dispatch Schema to Clients"
    runs-on: ubuntu-latest

    strategy:
      matrix:
        client_repo:
          - ladybug-tools/lbt-grasshopper

    steps:
    - name: "send repo dispatch to lbt-grasshopper"
      env:
        RELEASE_TAG: ${{ github.event.release.tag_name }}
        DISPATCH_URL: https://api.github.com/repos/${{ matrix.client_repo }}/dispatches
        GH_TOKEN: ${{ secrets.GH_TOKEN }}
      run: |
        curl -X POST $DISPATCH_URL \
          -H "Accept: application/vnd.github.everest-preview+json" \
          -d '{
            "event_type": "honeybee_openstudio_gem_release",
            "client_payload": {
              "version" : "'$RELEASE_TAG'"
            }
          }' \
          -u ladybugbot:$GH_TOKEN