-
Notifications
You must be signed in to change notification settings - Fork 5
/
cmd.ps1
24 lines (22 loc) · 902 Bytes
/
cmd.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$headers = @{
Authorization = "token $env:GITHUBPAT"
};
$tokenLevel = "orgs";
if ($env:GITHUBREPO_OR_ORG.IndexOf('/') -gt 0) {
$tokenLevel = "repos"
};
$registrationToken = ($(Invoke-WebRequest -UseBasicParsing -Uri "https://api.github.com/$tokenLevel/$env:GITHUBREPO_OR_ORG/actions/runners/registration-token" -Headers $headers -Method POST).Content | ConvertFrom-Json).token;
.\config.cmd --url "https://github.com/$env:GITHUBREPO_OR_ORG" --token "$registrationToken" --name $env:GITHUBRUNNERNAME --unattended --replace ;
Start-Process -FilePath ".\run.cmd"
$failureCount = 0
$maxFailureCount = 3
while ($failureCount -lt $maxFailureCount) {
Start-Sleep -Seconds 10;
if ($Null -eq (get-process "Runner.Listener" -ea SilentlyContinue)) {
$failureCount++;
Write-Host "not running ($failureCount / $maxFailureCount)"
}
else {
$failureCount = 0;
}
}