That example auto action is meant for profile update or registration. It's checking if the value of the field has changed. You'll need different conditions to handle login. The below should work for you.
Global
Triggers: onAfterLogin
Type: Usergroup
User: Automatic
Access: Everybody
Conditions
Condition 1
Field: Usergroups
User: Action User
Operator: Does Not Have
Usergroups: USERGROUP_TO_ADD_HERE
Condition 2
Field: email
Operator: Is REGEX
Value: EMAIL_DOMAIN_REGEXP
Action
Mode: Add Usergroups
Groups: USERGROUP_TO_ADD_HERE
Replace USERGROUP_TO_ADD_HERE with the usergroup or usergroups you want to add to the user in both the condition and the action. The condition is to ensure we don't try and add a usergroup they already have. Next you'll need to write the regex for EMAIL_DOMAIN_REGEXP to match the domains. Example as follows.
Code:
/@(domain_1\.com|domain_2\.com)$/
Each new domain is separated with | and be sure to escape the period with \ so it will actually be treated as a period.