Skip to content

Commit 985ac91

Browse files
authored
Merge pull request #215 from JaminenB/add_member_organization
Update app.py for ADD_MEMBER attribute
2 parents 743e8a8 + 34254cc commit 985ac91

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

app.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,19 @@ def execute_sync(org, team, slug, state):
211211
raise AssertionError(message)
212212
else:
213213
for user in state["action"]["add"]:
214-
# Validate that user is in org
215-
if org.is_member(user) or ADD_MEMBER:
214+
# Add user to org if they are not already a member and the ADD_MEMBER attribute is "true"
215+
if not org.is_member(user) and ADD_MEMBER:
216+
try:
217+
print(f"User: {user} is not in the {org.login} organization. Attempting to add.")
218+
org.add_or_update_membership(user)
219+
except Exception as e:
220+
print(f"Error adding {user} to {org.login}: {e}")
221+
pass
222+
else:
223+
print(f"User: {user} is already a member of the {org.login} organization or ADD_MEMBER is false")
224+
225+
# Add user to team if they are a member of the org
226+
if org.is_member(user):
216227
try:
217228
print(f"Adding {user} to {slug}")
218229
team.add_or_update_membership(user)

0 commit comments

Comments
 (0)