  We introduce the notion of a self-similar action of a groupoid $G$ on a
finite higher-rank graph. To these actions we associate a compactly aligned
product system of Hilbert bimodules, and thereby obtain corresponding universal
Nica--Toeplitz and Cuntz--Pimsner algebras. We consider natural actions of the
real numbers on both algebras and study the KMS states of the associated
dynamics. For large inverse temperatures, we describe the simplex of KMS states
on the Nica--Toeplitz algebra in terms of traces on the full $C^*$-algebra of
$G$. We prove that if the graph is $G$-aperiodic and the action satisfies a
finite-state condition, then there is a unique KMS state on the Cuntz--Pimsner
algebra.
