@@ -15,6 +15,10 @@ param (
15
15
[ValidateNotNullOrEmpty ()]
16
16
[string ]$GithubActionsRunnerName ,
17
17
18
+ [Parameter (Mandatory = $false , HelpMessage = " Start an ephemeral runner (this is the default)" )]
19
+ [ValidateSet (' true' , ' false' )]
20
+ [string ]$Ephemeral = ' true' ,
21
+
18
22
[Parameter (Mandatory = $false , HelpMessage = " Stop Service immediately (useful for spinning up runners preemptively)" )]
19
23
[ValidateSet (' true' , ' false' )]
20
24
[string ]$StopService = ' true' ,
@@ -261,12 +265,17 @@ Write-Output "Installing GitHub Actions runner $($GitHubAction.Tag) as a Windows
261
265
262
266
Add-Type - AssemblyName System.IO.Compression.FileSystem ; [System.IO.Compression.ZipFile ]::ExtractToDirectory($GitHubAction.OutFile , $GitHubActionsRunnerPath )
263
267
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
+ }
267
276
268
277
Write-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}
270
279
271
280
# Ensure that the service was created. If not, exit with error code.
272
281
if ($null -eq (Get-Service - Name " actions.runner.*" )) {
0 commit comments