Add error check for head ref
Move github workaround to github module
Clean up logs