This is the Domain of Eldritch Knight Fighter, Blade Singer Wizard and Valor Bard. These three subclasses all have the ability to switch an attack for a cantrip when taking the attack action from their respective forms of Extra Attack.
Notably using Metamagics Sorcerer can also perform an attack and cast a spell/cantrip on the same turn but that costs Sorcery Points and the bonus action, this is using the quickened spell metamagic.
Thirsting Blade said
" Prerequisites: 5th level, Pact of the Blade
You can attack with your pact weapon twice, instead of once, whenever you take the Attack action on your turn."
will it work if you cast Green Flame Blade and then attack?
No.
The Attack action is not the same thing as making an attack.
In this case you are taking the Magic action to cast a spell. That spell lets you make an attack, but it still isn't coming from the Attack action.
This is the Domain of Eldritch Knight Fighter, Blade Singer Wizard and Valor Bard. These three subclasses all have the ability to switch an attack for a cantrip when taking the attack action from their respective forms of Extra Attack.
Notably using Metamagics Sorcerer can also perform an attack and cast a spell/cantrip on the same turn but that costs Sorcery Points and the bonus action, this is using the quickened spell metamagic.