Don't worry about taking Communion. You did not commit a mortal sin.
Three conditions are necessary for mortal sin to exist:
Grave Matter: The act itself is intrinsically evil and immoral. For example, murder, rape, incest, perjury, adultery, and so on are grave matter.
Full Knowledge: The person must know that what they’re doing or planning to do is evil and immoral. For example, someone steals a postage stamp, thinking that it’s only worth 50 cents. She knows that it’s sinful, but if she’s unaware that the stamp is rare and actually worth a $1,000, she’s not guilty of mortal sin but of venial sin.
Deliberate Consent: The person must freely choose to commit the act or plan to do it. Someone forced against her will doesn’t commit a mortal sin. For example, a woman told she’s giving a minor shock to another person who in fact is administering tortuous electrical jolts is not guilty of a mortal sin (although she may feel guilty if she finds out the truth).
Here, you did not know the rule and did not know what you were doing. No one made an effort to educate you until after. Thus, you did not satisfy the knowledge element. Therefore, you could not have committed a mortal sin.
Don't do it again.