-
Notifications
You must be signed in to change notification settings - Fork 5
85 lines (74 loc) · 3.17 KB
/
windows-nightly-ci.yml
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
name: Windows Nightly Run
on: [push]
jobs:
start-ec2-instance:
uses: ./.github/workflows/provision-runner.yml
with:
ec2-image-id: ami-01fa2492704e48175
ec2-instance-type: t2.micro
security-group-id: sg-0a3e6b53e86d0e69d
subnet-id: subnet-06113672589e7e836
ec2-os-type: windows
secrets:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
github-token: ${{ secrets.GH_RUNNER_API_TOKEN }}
nonadmin-password: ${{ secrets.NONADMIN_PASSWORD }}
run-tests:
needs: start-ec2-instance
runs-on: ${{ needs.start-ec2-instance.outputs.instance_label }}
steps:
- name: Install nodeJS
shell: powershell
run: |
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
}
choco install nodejs -y
- name: Write Test Script
shell: powershell
run: |
# Ensure the directory exists
$runnerDir = "C:\Users\nonadmin\Documents\actions-runner\work"
if (-not (Test-Path -Path $runnerDir)) {
New-Item -Path $runnerDir -ItemType Directory -Force
}
$scriptContent = @"
code --version
node --version
"@
$scriptPath = "$runnerDir\run-tests.ps1"
$scriptContent | Out-File -FilePath $scriptPath -Encoding utf8 -Force
- name: Run Test Script as Non-Admin
shell: powershell
run: |
$password = ConvertTo-SecureString -String "${{ secrets.NONADMIN_PASSWORD }}" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("nonadmin", $password)
# Redirect output to separate log files
$logPathOut = "$runnerDir\run-tests-output.log"
$logPathErr = "$runnerDir\run-tests-error.log"
# Run script inline
Start-Process -FilePath "powershell.exe" `
-ArgumentList "-File $scriptPath" `
-Credential $credential `
-NoNewWindow `
-RedirectStandardOutput $logPathOut `
-RedirectStandardError $logPathErr `
# Output log files to GitHub Actions
Write-Output "--- Run Output ---"
Get-Content -Path $logPathOut
Write-Output "--- Run Error ---"
Get-Content -Path $logPathErr
# stop-ec2-instance:
# needs: [ start-ec2-instance, run-tests ]
# if: always()
# uses: ./.github/workflows/remove-runner.yml
# with:
# ec2-instance-id: ${{ needs.start-ec2-instance.outputs.ec2-instance-id }}
# ec2-runner-label: ${{ needs.start-ec2-instance.outputs.instance_label }}
# secrets:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# github-token: ${{ secrets.GH_RUNNER_API_TOKEN }}