Is spill the beans a metaphor?

No, “spill the beans” is an idiom, not a metaphor.

An idiom is an expression that cannot be understood based on the meaning of the individual words that comprise it (e.g., “once in a blue moon”).

A metaphor compares two unrelated things by stating that one is (or isn’t) like the other (e.g., “Laura is the light of my life.”)