You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# GitHub Actions Runner registration token. Note that these tokens are only valid for one hour after creation, so we always expect the user to provide one.
[Parameter(Mandatory=$true,HelpMessage="GitHub Actions Runner registration token. Note that these tokens are only valid for one hour after creation, so we always expect the user to provide one.")]
5
4
[string]$GitHubActionsRunnerToken,
6
5
7
6
# GitHub Actions Runner repository. E.g. "https://github.com/MY_ORG" (org-level) or "https://github.com/MY_ORG/MY_REPO" (repo-level)
if((Get-FileHash-Path $GitForWindowsOutputFile-Algorithm SHA256).Hash.ToUpper() -ne$GitForWindowsHash.ToUpper()){ throw'Computed checksum did not match' }
140
+
if ((Get-FileHash-Path $GitHubGit.OutFile-Algorithm SHA256).Hash.ToUpper() -ne$GitHubGit.Hash) {
141
+
Write-Error"Computed checksum for $($GitHubGit.OutFile) did not match $($GitHubGit.Hash)"
if((Get-FileHash-Path ${GitHubActionsRunnerPath}\actions-runner-win-${GithubActionsRunnerArch}-${GitHubActionsRunnerVersion}.zip-Algorithm SHA256).Hash.ToUpper() -ne$GithubActionsRunnerHash.ToUpper()){ throw'Computed checksum did not match' }
112
186
113
-
Write-Output"Installing GitHub Actions runner ${GitHubActionsRunnerVersion} as a Windows service with labels ${GithubActionsRunnerLabels}..."
187
+
if ((Get-FileHash-Path $GitHubAction.OutFile-Algorithm SHA256).Hash.ToUpper() -ne$GitHubAction.hash) {
188
+
Write-Error"Computed checksum for $($GitHubAction.OutFile) did not match $($GitHubAction.hash)"
Write-Error"GitHub Actions service not found (should start with actions.runner). Check the logs in ${GitHubActionsRunnerPath}\_diag for more details."
128
-
exit1
204
+
if ($null-eq (Get-Service-Name "actions.runner.*")) {
205
+
Write-Output"Could not find service actions.runner.*, making three more attempts with a 3 second delay in between each attempt..."
206
+
207
+
[int]$RetryCountService=0
208
+
do {
209
+
Write-Output"Attempt $($RetryCountService) of 3: Looking for service actions.runner.*..."
210
+
$RetryCountService++
211
+
Start-Sleep-Seconds 3
212
+
}
213
+
while ($null-eq (Get-Service-Name "actions.runner.*") -or$RetryCountService-gt3)
214
+
215
+
if ($RetryCountService-gt3) {
216
+
Write-Error"GitHub Actions service not found (should start with actions.runner). Check the logs in ${GitHubActionsRunnerPath}\_diag for more details."
217
+
exit1
218
+
}
219
+
else {
220
+
Write-Output"Found service actions.runner.*"
221
+
}
129
222
}
130
223
131
224
# Immediately stop the service as we want to leave the VM in a deallocated state for later use. The service will automatically be started when Windows starts.
132
-
if (${StopService}-eq'true') {
133
-
Stop-Service-Name "actions.runner.*"-Verbose
225
+
if ($StopService-eq'true') {
226
+
#Collects all running services named actions.runner.*
227
+
$GetActionRunnerServices=Get-Service-Name "actions.runner.*"|Where-Object { $_.Status-eq'Running' } |Select-Object-ExpandProperty Name
228
+
229
+
# Loops trough all services and stopping them one by one
230
+
foreach ($Servicein$GetActionRunnerServices) {
231
+
Write-Output"Stopping service $Service"
232
+
Stop-Service-Name $Service
233
+
234
+
# Making sure that all of the services has been stopped before moving forward
235
+
[int]$RetryCount=0
236
+
do {
237
+
Write-Output"Attempt: $($RetryCount) of 5: Waiting for service $Service to stop..."
238
+
$RetryCount++
239
+
Start-Sleep-Seconds 5
240
+
}
241
+
while ((Get-Service-Name $Service).Status -eq'running'-or$RetryCount-gt5)
0 commit comments