@@ -15,6 +15,10 @@ param (
1515 [ValidateNotNullOrEmpty ()]
1616 [string ]$GithubActionsRunnerName ,
1717
18+ [Parameter (Mandatory = $false , HelpMessage = " Start an ephemeral runner (this is the default)" )]
19+ [ValidateSet (' true' , ' false' )]
20+ [string ]$Ephemeral = ' true' ,
21+
1822 [Parameter (Mandatory = $false , HelpMessage = " Stop Service immediately (useful for spinning up runners preemptively)" )]
1923 [ValidateSet (' true' , ' false' )]
2024 [string ]$StopService = ' true' ,
@@ -261,12 +265,17 @@ Write-Output "Installing GitHub Actions runner $($GitHubAction.Tag) as a Windows
261265
262266Add-Type - AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile ]::ExtractToDirectory($GitHubAction.OutFile , $GitHubActionsRunnerPath )
263267
264- Write-Output " Configuring the runner to shut down automatically after running"
265- Set-Content - Path " ${GitHubActionsRunnerPath} \shut-down.ps1" - Value " shutdown -s -t 60 -d p:4:0 -c `" workflow job is done`" "
266- [System.Environment ]::SetEnvironmentVariable(" ACTIONS_RUNNER_HOOK_JOB_COMPLETED" , " ${GitHubActionsRunnerPath} \shut-down.ps1" , [System.EnvironmentVariableTarget ]::Machine)
268+ If ($Ephemeral -ne ' true' ) {
269+ $EphemeralOption = " "
270+ } Else {
271+ $EphemeralOption = " --ephemeral"
272+ Write-Output " Configuring the runner to shut down automatically after running"
273+ Set-Content - Path " ${GitHubActionsRunnerPath} \shut-down.ps1" - Value " shutdown -s -t 60 -d p:4:0 -c `" workflow job is done`" "
274+ [System.Environment ]::SetEnvironmentVariable(" ACTIONS_RUNNER_HOOK_JOB_COMPLETED" , " ${GitHubActionsRunnerPath} \shut-down.ps1" , [System.EnvironmentVariableTarget ]::Machine)
275+ }
267276
268277Write-Output " Configuring the runner"
269- cmd.exe / c " ${GitHubActionsRunnerPath} \config.cmd" -- unattended -- ephemeral -- name ${GithubActionsRunnerName} -- runasservice -- labels $ ($GitHubAction.RunnerLabels ) -- url ${GithubActionsRunnerRegistrationUrl} -- token ${GitHubActionsRunnerToken}
278+ cmd.exe / c " ${GitHubActionsRunnerPath} \config.cmd" -- unattended $EphemeralOption -- name ${GithubActionsRunnerName} -- runasservice -- labels $ ($GitHubAction.RunnerLabels ) -- url ${GithubActionsRunnerRegistrationUrl} -- token ${GitHubActionsRunnerToken}
270279
271280# Ensure that the service was created. If not, exit with error code.
272281if ($null -eq (Get-Service - Name " actions.runner.*" )) {
0 commit comments