This document reports the measurement of the rate of the associated production of a Higgs boson and a pair of top-antitop quarks (tH), with the Higgs boson decaying into a pair of photons. Events with two photons are selected from a sample of proton-proton collisions at a center-of-mass energy \sqrt{s}=13~\mathrm{TeV} collected by the CMS detector at the LHC in 2017, corresponding to an integrated luminosity of 41.5~\mathrm{fb}^{-1}. The tH production is identified by requiring the presence of top quark decay products in the final state. The measured cross section, normalized to the standard model prediction, is 1.3. The combination with the published result using 35.9~\mathrm{fb}^{-1} of data recorded in 2016 at a center-of-mass energy \sqrt{s}=13~\mathrm{TeV} is also reported. The combined best fit cross section, normalized to the standard model prediction, is found to be 1.7. All results are found in agreement with the standard model expectation.