Action and entropy of black holes in spacetimes with a cosmological constant