name: PyTorch CI Trigger

run-name: >-
  PyTorch CI Trigger -
  ${{
    github.event.client_payload.event_type == 'pull_request' &&
    format(
      'PR #{0} ({1})',
      github.event.client_payload.payload.pull_request.number,
      github.event.client_payload.payload.action
    ) ||
    format('Push {0}', github.event.client_payload.payload.after)
  }}
on:
  repository_dispatch:
    types: [pull_request, push]

concurrency:
  group: >-
    ci-${{ github.event.client_payload.payload.repository.full_name }}-${{
    github.event.client_payload.payload.pull_request.number || github.run_id }}
  cancel-in-progress: true

permissions:
  contents: read
  id-token: write  # Required by report-ci-result to obtain an OIDC token

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Print full github.event
        run: |
          echo '=== FULL github.event ==='
          echo '${{ toJSON(github.event) }}' | jq .
      - name: Print full client_payload
        run: |
          echo '=== FULL client_payload ==='
          echo '${{ toJSON(github.event.client_payload) }}' | jq .
      - name: Print key fields
        run: |
          echo "=== KEY FIELDS ==="
          echo "event_type:       ${{ github.event.client_payload.event_type }}"
          echo "action:           ${{ github.event.client_payload.payload.action }}"
          echo "repo.full_name:   ${{ github.event.client_payload.payload.repository.full_name }}"
          echo "sender:           ${{ github.event.client_payload.payload.sender.login }}"
          echo "downstream_repo:  ${{ github.repository }}"
          echo "github.run_id:    ${{ github.run_id }}"