Gibbs Free Energy Spontaneity Criterion Derivation
For a system in contact with a constant temperature reservoir at the same temperature as the system in its initial state, and also in contact with a constant pressure surrounding at the same pressure as the system in its initial state, $$\Delta U=Q-W=Q-P\Delta V-W_{npv}$$where $W_{npv}$ is the amount of non-PV work done by the system.  In addition, from the 2nd law of thermodynamics, we have $$\Delta S=\frac{Q}{T}+\sigma$$where $\frac{Q}{T}$ is the amount of entropy transferred to the system from the surroundings across the interface between the system and surroundings (recall that the latter is always at the initial temperature of the material comprising the system).  Note that this does not say anything about how the temperature may be varying with location and time within the internals of the system during the process.  In addition, the parameter $\sigma$ represents the amount of entropy generated within the system due to irreversibilities during the process. Note that $\sigma$ can only be positive (irreversible process) or zero (reversible process)
If we combine these two equations, we obtain:
$$\Delta U=T\Delta S-T\sigma-P\Delta V-W_{npv}$$or$$\Delta G=-W_{npv}-T\sigma$$ According to this, if no non-PV is done by the system on the surroundings during the process, $\Delta G$ must be negative (irreversible) or zero (reversible).