REBELinBLUE\Deployer\Http\Webhooks\Github::handlePush PHP Method

handlePush() public method

Parses the request for a push webhook body.
public handlePush ( ) : mixed
return mixed Either an array of parameters for the deployment config, or false if it is invalid.
    public function handlePush()
    {
        // We only care about push events
        if ($this->request->header('X-GitHub-Event') !== 'push') {
            return false;
        }
        $payload = $this->request->json();
        // Github sends a payload when you close a pull request with a non-existent commit.
        if ($payload->has('after') && $payload->get('after') === '0000000000000000000000000000000000000000') {
            return false;
        }
        $head = $payload->get('head_commit');
        $branch = preg_replace('#refs/(tags|heads)/#', '', $payload->get('ref'));
        return ['reason' => trim($head['message']), 'branch' => $branch, 'source' => 'Github', 'build_url' => $head['url'], 'commit' => $head['id'], 'committer' => $head['committer']['name'], 'committer_email' => $head['committer']['email']];
    }