Constructing group actions on quasi-trees and applications to mapping class groups