Animated gifs can be accessible if they are set to stop after 5 seconds or if users are presented with a way to pause it, if they have alt text and if they do not contain blinking/flashing.
You should also ask yourself if there is another way that the message can be communicated. Would a still image do? If not, think about providing an alternative or some way that users can forgo the animation or switch to an embedded video.
A useful tool when checking your gifs for flashing may be this Photosensitive Epilepsy Analysis Tool. You want to make sure the animation won't trigger seizures in people who are sensitive to flashing.