Graded Lie algebra and generalized Chern-Simons actions in arbitrary dimensions