parameters:
- name: repoName
  type: string
  default: ''
- name: eventType
  type: string
  default: ''
- name: azureBuildNumber
  type: string
  default: ''
- name:  githubActionsToken
  type: string
  default: ''

steps:
- task: Bash@3
  name: ghActionsPost
  displayName: Post a request to a github repository with a repository_dispatch workflow
  continueOnError: true
  inputs:
    targetType: inline
    workingDirectory: $(Build.SourcesDirectory) 
    script: |
      curl -L -X POST \
        -H "Accept: application/vnd.github+json" \
        -H "Authorization: Bearer ${{ parameters.githubActionsToken }}" \
        -H "X-GitHub-Api-Version: 2022-11-28" \
        https://api.github.com/repos/${{ parameters.repoName }}/dispatches \
        -d '{
          "event_type": "${{ parameters.eventType }}",
          "client_payload": {
            "azure-job-id": "${{ parameters.azureBuildNumber }}"
          }
        }'