I got hacked a month ago because of this mistake. Someone initiated 15 heavy duty aws instances on my account. Luckily aws support noticed the huge increase in billing and called me to confirm. Now my github is private haha.
That is not the solution. You're supposed to isolate secrets from the code repository.