Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 6

Webhook push action does not always contain

I'm working on automating the scanning of commits for secrets using a package called gitleaks.  Currently I've got a webhook listening for github push events.  Once received I extract the from the payload and run a scan against that specific commit.


In some cases I receive a push event from github where the payload contains 'null' for the value of the field.  


I believe this has something to do with pull requests but I cannot find any documentation that confirms my suspicion.  Any insight I can get from the community on why I would get a 'null' value for the would be much appreciated.  Thanks.

5 Replies
GitHub Partner
Message 2 of 6

Re: Webhook push action does not always contain

Github push events always have But when a workflow is triggered by pull request event, there is no in github context . Please check whether your webhook listens to pull request event either.


You could add next step to your workflow, to check the github context.

 - run: echo $GITHUB_CONTEXT
        GITHUB_CONTEXT: ${{ toJson(github) }}


Copilot Lvl 2
Message 3 of 6

Re: Webhook push action does not always contain

Thank you for this information.  I've just confirmed that some push events i'm seeing with no are unrelated to workflows/actions.  Could a pull request or a merge of pull request get pushed without a ?

GitHub Partner
Message 4 of 6

Re: Webhook push action does not always contain

Sorry to tell your that whatever the commit is a normal one or a pull request merged one, the push event always includes This could not be changed. 

Copilot Lvl 2
Message 5 of 6

Re: Webhook push action does not always contain

Thanks again for following up.  I'm working with git enterprise and I am in fact seeing push events without the  Also I was doing some research and found a reference in the git api documentation that shows a push event without the head_commit, but I'm not quite sure in which scenario this would apply.  See below.  Any thoughts on what scenario this example is relevant to?


In the payload example under PushEvent, it shows a head_commit of null.


Screen Shot 2020-01-09 at 10.21.58 AM.png

GitHub Partner
Message 6 of 6

Re: Webhook push action does not always contain

Sorry for my previous assertion: The push event always includes  I forgot the push operation for deleting a tag. 

The Webhook payload example on document is for a delete tag push event. 

I tried to add a webhook in my github repo, when I run next command: 

git push --delete origin {tag_name}

I could see a new delivery in Webhook page: 


Check its Payload, the head_commit is null.


You could add some code to exclude the scenario when push to delete tags.