{
  "$id": "https://firefox-ci-tc.services.mozilla.com/schemas/github/v1/webhook-pull-request-payload.json#",
  "$schema": "https://firefox-ci-tc.services.mozilla.com/schemas/common/metaschema.json#",
  "additionalProperties": true,
  "description": "Validates GitHub pull request event webhook payload.\nStrictly validates fields that caused issues in PR #7958.\n",
  "properties": {
    "action": {
      "description": "The action performed on the pull request.\nCommon values: opened, closed, reopened, synchronize, edited, assigned,\nunassigned, labeled, unlabeled, review_requested, review_request_removed,\nready_for_review, converted_to_draft, locked, unlocked, auto_merge_enabled,\nauto_merge_disabled, enqueued, dequeued, milestoned, demilestoned, etc.\nGitHub may add new action types; validation accepts any non-empty string.\n",
      "minLength": 1,
      "type": "string"
    },
    "installation": {
      "additionalProperties": true,
      "properties": {
        "id": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "id"
      ],
      "type": "object"
    },
    "number": {
      "minimum": 1,
      "type": "integer"
    },
    "pull_request": {
      "additionalProperties": true,
      "properties": {
        "base": {
          "additionalProperties": true,
          "properties": {
            "ref": {
              "minLength": 1,
              "type": "string"
            },
            "repo": {
              "additionalProperties": true,
              "properties": {
                "clone_url": {
                  "format": "uri",
                  "type": "string"
                },
                "full_name": {
                  "pattern": "^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$",
                  "type": "string"
                },
                "name": {
                  "pattern": "^[A-Za-z0-9._-]+$",
                  "type": "string"
                },
                "owner": {
                  "additionalProperties": true,
                  "anyOf": [
                    {
                      "required": [
                        "name"
                      ]
                    },
                    {
                      "required": [
                        "login"
                      ]
                    }
                  ],
                  "properties": {
                    "login": {
                      "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
                      "type": "string"
                    },
                    "name": {
                      "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              },
              "required": [
                "name",
                "full_name",
                "clone_url",
                "owner"
              ],
              "type": "object"
            },
            "sha": {
              "pattern": "^[a-f0-9]{40}$",
              "type": "string"
            }
          },
          "required": [
            "sha",
            "ref",
            "repo"
          ],
          "type": "object"
        },
        "head": {
          "additionalProperties": true,
          "properties": {
            "ref": {
              "minLength": 1,
              "type": "string"
            },
            "repo": {
              "additionalProperties": true,
              "properties": {
                "clone_url": {
                  "format": "uri",
                  "type": "string"
                },
                "full_name": {
                  "pattern": "^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$",
                  "type": "string"
                },
                "name": {
                  "pattern": "^[A-Za-z0-9._-]+$",
                  "type": "string"
                },
                "owner": {
                  "additionalProperties": true,
                  "anyOf": [
                    {
                      "required": [
                        "name"
                      ]
                    },
                    {
                      "required": [
                        "login"
                      ]
                    }
                  ],
                  "properties": {
                    "login": {
                      "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
                      "type": "string"
                    },
                    "name": {
                      "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              },
              "required": [
                "name",
                "full_name",
                "clone_url",
                "owner"
              ],
              "type": "object"
            },
            "sha": {
              "pattern": "^[a-f0-9]{40}$",
              "type": "string"
            }
          },
          "required": [
            "sha",
            "ref",
            "repo"
          ],
          "type": "object"
        },
        "number": {
          "minimum": 1,
          "type": "integer"
        },
        "state": {
          "enum": [
            "open",
            "closed"
          ],
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "user": {
          "additionalProperties": true,
          "properties": {
            "login": {
              "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
              "type": "string"
            }
          },
          "required": [
            "login"
          ],
          "type": "object"
        }
      },
      "required": [
        "number",
        "state",
        "head",
        "base",
        "user"
      ],
      "type": "object"
    },
    "repository": {
      "additionalProperties": true,
      "properties": {
        "full_name": {
          "pattern": "^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$",
          "type": "string"
        },
        "owner": {
          "additionalProperties": true,
          "anyOf": [
            {
              "required": [
                "name"
              ]
            },
            {
              "required": [
                "login"
              ]
            }
          ],
          "properties": {
            "login": {
              "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
              "type": "string"
            },
            "name": {
              "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
              "type": "string"
            }
          },
          "type": "object"
        }
      },
      "required": [
        "full_name",
        "owner"
      ],
      "type": "object"
    },
    "sender": {
      "additionalProperties": true,
      "properties": {
        "login": {
          "pattern": "^([a-zA-Z0-9-_%\\[\\]]*)$",
          "type": "string"
        }
      },
      "required": [
        "login"
      ],
      "type": "object"
    }
  },
  "required": [
    "action",
    "number",
    "pull_request",
    "repository",
    "sender"
  ],
  "title": "GitHub Pull Request Webhook Payload",
  "type": "object"
}