debian – Automatic recompilation when arbitrary package is upgraded

How one would hook on apt updates to automatically download arbitrary sources and compile them when select packages are modified ? (Upgrade or downgrade)

How to proceed ?
Said source could be from deb-src, https or git.
Example usage would be to compile modsecurity bridge for nginx when nginx or libmodsecurity is updated. Corresponding sourcecode should be gathered to match the updated package.

Would one require to use a whole platform like Jenkins for this ?
It also looks like such platform would not track deb-src