How does Sanctuary interacts with “reflected” damages?

Through a peculiar course of events with a touch of homebrew, my cleric got to learn the spell Armor of Agathys. As a regular user of the Sanctuary spell, I wondered how these spells would interact in the following situation:

  1. Casting Sanctuary on myself as soon as fight starts
  2. Casting Armor of Agathys to add an additional defense
  3. A goblin succeeds the Sanctuary saving throw and hits me with a melee attack
  4. A goblin takes damages due to Armor of Agathys.

Does the Sanctuary spell end because I casted Armor of Agathys and after Sanctuary and the spell affects the gobelin when it takes damages ?

Would Sanctuary end if I were to cast Armor of Agathys 10 mins ago because this dark and shadowy dungeon looked dangerous ?

Would Sanctuary break if the damage reflection came from the effect of racial trait or a kinda spiky enchanted armour ?