Something earns you something else cannot be translated with gagner directly. The subject of gagner is necessarily the “recipient” for this action in French. Quelqu'un gagne quelque chose (grace à autre chose).
Therefore only the first construction is correct.
Only a very limitted set of verbs could produce two valid sentences that match your scheme. It's possible when the verb admits transitive and intransitive variants. Like sortir: both Je sors and Cela te sortira de la routine quotidiene exist. The meaning is only slightly different. In this case you can use the following almost interchangeably:
Travailler te fera sortir d'ici.
Travailler te sortira d'ici.
But in gerenal only one of the two forms is possible, because the person is either the subject (first form) or the object of the verb (second form).