My high school did that. It was a private school, though, so I think it was within their rights to require community service before handing out one of their diplomas.
As did my public HS, back in the '90s, it was called 'community service', was required to pass a class that was mandatory for graduating, and had been for decades.
It was easy enough.