SNP struck deal with Greens to 'avoid no confidence motions