Photons are gauge bosons, they do not have spins or magnetic moments!
For electrons, bose/fermi atoms in a magnetic field, we have the energy $$E({\bf r})=\boldsymbol{\mu}\cdot {\bf B}({\bf r})$$ where $\boldsymbol{\mu}$ is the magnetic moment.
Hence we have force due to the gradient of magnetic field, $$F=-\nabla E({\bf r})=-\mu\nabla{B}({\bf r})$$$${\bf F}=-\nabla E({\bf r})=-\mu\nabla{B}({\bf r})$$ which produces Stern-Gerlach effect. You cannot write down a "photonic version" of this.