Action-based models for dwarf spheroidal galaxies and globular clusters