Custom hook not working. The code I try to hook is not being placed correctly.

Hello!

I am trying to create a custom hook, because there is not a built in hook in the correct location. I created a hook like so:

<?php function my_hook(){
    do_action('my_hook');
  } ?>

And I placed the hook function where I want it:

<?php echo '<div class=&quot;featured-image-container&quot; style=&quot;background: url(' . $thumb_url . ');&quot;><div class=&quot;entry-title-container&quot;><h1 class=&quot;entry-title&quot;>' . get_the_title() . '</h1></div>' .
        my_hook()
  . '</div>'; ?>

But when I try using it:

<?php function test_run(){
    echo &quot;this is a test run.&quot;;
}
add_action(my_hook, test_run); ?>

The text gets placed ABOVE the "featured-image-container" div, not INSIDE of it where I placed the hook function.

I don't know if this is the correct way of doing this.

Please advise.

Cheers!