-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLos
180 lines (64 loc) · 2.65 KB
/
Los
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: CI
on: [push, workflow_dispatch]
jobs:
build:
runs-on: windows-latest
steps:
- name: Download
run: Invoke-WebRequest https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-windows-amd64.zip -OutFile ngrok.zip
- name: Extract
run: Expand-Archive ngrok.zip
- name: Auth
run: .\ngrok\ngrok.exe authtoken $Env:NGROK_AUTH_TOKEN
env:
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
- name: Enable TS
run: Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
- run: Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
- run: Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1
- run: Set-LocalUser -Name "runneradmin" -Password (ConvertTo-SecureString -AsPlainText "P@ssw0rd!" -Force)
- name: Start ngrok in the background
run: Start-Process -FilePath ".\ngrok\ngrok.exe" -ArgumentList "tcp 3389"
- name: Wait for ngrok to start
run: Start-Sleep -Seconds 5
- name: Get ngrok tunnel information
run: |
$maxAttempts = 20
$attempts = 0
$ngrokApi = $null
while (($null -eq $ngrokApi) -and ($attempts -lt $maxAttempts)) {
$attempts += 1
try {
$ngrokApi = Invoke-WebRequest "http://localhost:4040/api/tunnels"
} catch {
Write-Host "Waiting for ngrok API... (attempt $attempts of $maxAttempts)"
Start-Sleep -Seconds 5
}
}
if ($null -eq $ngrokApi) {
throw "Failed to connect to ngrok API after $maxAttempts attempts."
}
$ngrokUrl = ($ngrokApi | ConvertFrom-Json).tunnels[0].public_url
Write-Host "Ngrok URL: $ngrokUrl"
- name: Wait before cleanup
run: Start-Sleep -Seconds 3600
- name: Cleanup
if: always()
run: |
$ngrokProcess = Get-Process -Name "ngrok" -ErrorAction SilentlyContinue
if ($null -ne $ngrokProcess) {
Write-Host "Terminating ngrok process..."
$ngrokProcess | Stop-Process -Force
} else {
Write-Host "Ngrok process not found."
}
- name: Cleanup
if: always()
run: |
$ngrokProcess = Get-Process -Name "ngrok" -ErrorAction SilentlyContinue
if ($null -ne $ngrokProcess) {
Write-Host "Terminating ngrok process..."
$ngrokProcess | Stop-Process -Force
} else {
Write-Host "Ngrok process not found."
}