Skip to content

Instantly share code, notes, and snippets.

@edutrul
Created April 26, 2020 19:54
Show Gist options
  • Save edutrul/a7e8dcf67e3e02f2f63dca311214820f to your computer and use it in GitHub Desktop.
Save edutrul/a7e8dcf67e3e02f2f63dca311214820f to your computer and use it in GitHub Desktop.
Troubleshoot git webhook in Drupal 8

Make sure:

  • web/github/github.php has correct permissions

In github webhooks make sure you add domain

  • https://example-drupal.com/github/github.php IMPORTANT note check "https" In Content Type choose application/json
  • SSL Verification make sure it is enabled Which events would you like to trigger this webhook?
  • Push Check Active

Then a http request will be sent to your github.php (just to make sure it is all fine) you should green mark. Now add changes (any change "space" or comment) Then push it Refresh webhook page in github and should get a new request and response with:

this is supposed to work...Array ( [ref] => refs/heads/master [before] => 1632ee39c0e6152659bc367ffbeede064e5a645b [after] => 3bddd33e0956830845677ec37ebea5b125dd623f [repository] => Array ( [id] => 255094848 [node_id] => MDEwOlJlcG9zaXRvcnkyNTUwOTQ4NDg= [name] => pet-id-backend-cms [full_name] => edutrul/pet-id-backend-cms [private] => 1 [owner] => Array

# In your existing web/.httaccess make sure you a condition to ignore github.php from normal drupal stuff.
RewriteCond ^github/github.php [L]
<?php
/**
* @file
* Endpoint for Github Webhook URLs.
*
* See: https://help.github.com/articles/post-receive-hooks.
*/
print 'this is supposed to work... ';
// So we can read data from json data
$rawPost = file_get_contents('php://input');
$var = json_decode($rawPost, TRUE);
print_r($var);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment