actions: Factor parsing a single action into a new function parse_action().