I found a solution:
function my_function_to_run_on_autoupdate(array $results ): void {
// Iterate through the plugins being updated and check if ours is there.
foreach ( $results['plugin'] as $plugin ) {
if (
isset( $plugin->item->slug )
&& strlen( $plugin->item->slug ) > 0
// 'your-plugin-slug' is usually the folder name of your plugin
&& $plugin->item->slug === 'your-plugin-slug'
) {
// Run whatever you want to run
}
}
}
This will be executed every time there is a plugin auto-update. If it finds your plugin, the code in “if” will be executed.