According to my book(Elements of Physical Chemistry by Atkins and de Paula, 5th ed.), $\Delta G = - T \Delta S_{\mathrm{total}}$ is valid only for constant pressure and temperature.
Enthalpy is defined as $H = U + PV$. So, when pressure and volume both are not constant, $\Delta H = \Delta U + \Delta (PV)$. So, enthalpy can be defined even if the pressure is not constant.
Now the criterion for spontaneity is that $\Delta S_{\mathrm{total}} > 0$. But $$\Delta S_{\mathrm{total}} = \Delta S_{\mathrm{sys}} - \frac{\Delta H}{T}$$ where $T$ is the temperature of the surroundings. Now, if any heat enters the surroundings, the temperature of the surroundings does not change provided that the surroundings are large. I think that due to this the temperature of the system has essentially to be the same or infinitesimally greater/lesser than the surrounding temperature as the heat transfer has to take place reversibly.
But now, as $G = H - TS_{\mathrm{sys}}$, $$\Delta G = \Delta H - T\Delta S_{\mathrm{sys}}.$$
Thus, from comparison of equations, $\Delta G = -T \Delta S_{\mathrm{total}}$. So, I did not need to specify that pressure is constant and why does my book do so?