Try this. scan returns an array of arrays, each of which contains the capture groups from the regexp.
ruby {
code => '
matches = event.get("massage").scan(/ts_action\s*: ([^,]+), Action ID: ([^,]+)/)
matches.each_index { |x|
event.set("ts_action#{x+1}", matches[x][0])
event.set("action_id#{x+1}", matches[x][1])
}
'
}