check_github_access.py 936 B

12345678910111213141516171819202122232425262728293031
  1. from typing import Set, Tuple
  2. from devenv.lib import github
  3. tags: Set[str] = {"github"}
  4. name = "Check Github Access"
  5. def check() -> Tuple[bool, str]:
  6. result = github.check_ssh_access()
  7. if result:
  8. return True, "You have access to Github"
  9. return False, "You do not have access to Github"
  10. def fix() -> Tuple[bool, str]:
  11. github.add_to_known_hosts()
  12. if not github.check_ssh_access():
  13. pubkey = github.generate_and_configure_ssh_keypair()
  14. return (
  15. False,
  16. f"""
  17. Failed to authenticate with an ssh key to GitHub.
  18. We've generated and configured one for you at ~/.ssh/sentry-github.
  19. Visit https://github.com/settings/ssh/new and add the following Authentication key:
  20. {pubkey}
  21. Then, you need to go to https://github.com/settings/keys, find your key,
  22. and click Configure SSO, for the getsentry organization.
  23. """,
  24. )
  25. return True, "You have access to Github"