Animated gifs that repeat non-stop or more than 3 times in one second should be avoided.
To ensure compliance, animated images should stop after 5 seconds or users should be given a way to pause. They must also include alt text and if they contain blinking or flashing they should not flash more than 3 times in one second or if they flash in only one place on screen at a time and are quite small then they may be used. Refer to the following link to be sure: G176: Keeping the flashing area small enough
A tool such as the Photosensitive Epilepsy Analysis Tool may also be used to test for compliance.
Reference: WCAG 2.1 (Level A) – 2.3.1