Pipeline which requires the worker reboot in the between

Please advice, how to achieve the following with the help of gitlab-ci.

I have the application, which upgrades the OS from one version to another. The process of the upgrade assumes that the machine should be rebooted at some moment. Then the upgrade continues.

If imagine stages of the .gitlab-ci.yml I would write it something like:

  - system_configuration
  - upgrade_os_before_reboot  
  - upgrade_os_after_reboot
  - target_system_check

it is also important to restore the target machine into the initial state, so next upgrade could be tested.

Maybe custom executor of gitlab runner could help here, but before digging into it, I would like to get some advice.

I believe I have to solve the problem alone:(((