move code for gitHub api interaction outside fo ruby block