Each action will be as long as its last keyframe, for example if you push the action into the NLA, you'll see that the yellow strip will adapt to the action length.
As for the Timeline length, I don't think that there's any automatic way to make it last as long as the selected action, you need to put the player cursor at the last keyframe and press CtrlEnd, or type the End frame, or Playback > Set End Frame:
Maybe it could be possible to synchronized the end of the timeline to the last keyframe with a script? I think it deserves a button.
that said, you can temporarily frame the start and end with P, deactivate with AltP: