How to automatically assign a role based on email address domain?
Yes you could create your own (custom) Rules Condition. But in this case I don't think that's needed. The clue to what you're asking for, is a Rules Condition which is a "text comparison".

In that comparison, you use a regular expression to indicate "the email address should end with "@examplecompany.com".

For an example rule which also uses such RegEx-expressions, refer to the answer to "How to use the Rules module to perform a simple anti-spam validation using specific keywords?".

Be aware: I'm not a RegEx expert ..., but here a few dozens of similar examples using a RegEx ...

However, I predict you'll have multiple domains/roles to be processed. So the real Rules fun starts when this (typical) question arises: "I need to add something like a Rules Condition inside the Rules Actions, how can I do that?"

To resolve this typical question, there are basically 2 approaches (that I am aware of):


Use the Conditional Rules module. For an example using the Conditional Rules module (for which there is not a lot of docu available), refer to my answer to the question "How to prevent a node being saved when using the Rules module?".
Rework the relevant part of your Rules Action(s) into performing a Rules Component. Because in a Rules Component, it is possible to also add Rules Conditions.