Adds a team member to a team with team_name.

    name
        The name of the team member to add.

    team_name
        The name of the team of which to add the user.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_team_member 'user_name' 'team_name'

    .. versionadded:: 2016.11.0

def add_team_member(name, team_name, profile="github"):
    '''
    Adds a team member to a team with team_name.

    name
        The name of the team member to add.

    team_name
        The name of the team of which to add the user.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    CLI Example:

    .. code-block:: bash

        salt myminion github.add_team_member 'user_name' 'team_name'

    .. versionadded:: 2016.11.0
    '''
    team = get_team(team_name, profile=profile)
    if not team:
        log.error('Team %s does not exist', team_name)
        return False
    try:
        client = _get_client(profile)
        organization = client.get_organization(
            _get_config_value(profile, 'org_name')
        )
        team = organization.get_team(team['id'])
        member = client.get_user(name)
    except UnknownObjectException:
        log.exception('Resource not found: %s', team['id'])
        return False

    try:
        # Can't use team.add_membership due to this bug that hasn't made it into
        # a PyGithub release yet https://github.com/PyGithub/PyGithub/issues/363
        headers, data = team._requester.requestJsonAndCheck(
            "PUT",
            team.url + "/memberships/" + member._identity,
            input={'role': 'member'},
            parameters={'role': 'member'}
        )
    except github.GithubException:
        log.exception('Error in adding a member to a team')
        return False
    return True