How to Keep Processes Running After a GitHub Action Job Ends

 
 
  • Gérald Barré

When a GitHub Actions job finishes, the runner terminates any orphaned processes it started. It identifies these processes by checking for the RUNNER_TRACKING_ID environment variable. Any process with this variable set is treated as a child of the runner and will be stopped.

To allow a process to continue running after the job completes, start it without the RUNNER_TRACKING_ID environment variable set.

C#
var psi = new ProcessStartInfo("sample_app");
psi.EnvironmentVariables.Remove("RUNNER_TRACKING_ID");
Process.Start(psi);
PowerShell
# Options 1
$env:RUNNER_TRACKING_ID = $null

# Options 2
$psi = New-Object System.Diagnostics.ProcessStartInfo "sample_app"
$psi.EnvironmentVariables.Remove("RUNNER_TRACKING_ID")
[System.Diagnostics.Process]::Start($psi)

Do you have a question or a suggestion about this post? Contact me!

Follow me:
Enjoy this blog?Buy Me A Coffee💖 Sponsor on GitHub