def get_deploy_key_repo(deploy_repo, keypath, key_ext=''):
    """
    Return (repository of which deploy key is used, environment variable to store
    the encryption key of deploy key, path of deploy key file)
    """
    # deploy key of the original repo has write access to the wiki
    deploy_key_repo = deploy_repo[:-5] if deploy_repo.endswith('.wiki') else deploy_repo

    # Automatically determine environment variable and key file name from deploy repo name
    # Special characters are substituted with a hyphen(-) by GitHub
    snake_case_name = deploy_key_repo.replace('-', '_').replace('.', '_').replace('/', '_').lower()
    env_name = 'DOCTR_DEPLOY_ENCRYPTION_KEY_' + snake_case_name.upper()
    keypath = keypath or 'github_deploy_key_' + snake_case_name + key_ext

    return (deploy_key_repo, env_name, keypath)