Skip to content

Commit 61b78f1

Browse files
authored
feat: Windows support (#14)
1 parent cbdfc51 commit 61b78f1

File tree

2 files changed

+74
-5
lines changed

2 files changed

+74
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- 'main'
88

99
jobs:
10-
test:
10+
test-linux:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
@@ -48,4 +48,48 @@ jobs:
4848
echo Calling $TEST_URL 🚀
4949
curl -v $TEST_URL
5050
51-
- run: echo "SUCCESS!!! 🤩 This job's status is ${{ job.status }}."
51+
- run: echo "SUCCESS!!! 🤩 This job's status is ${{ job.status }}."
52+
53+
test-windows:
54+
strategy:
55+
max-parallel: 4
56+
matrix:
57+
runs-on: [windows-latest, windows-2025, windows-2022, windows-2019]
58+
include:
59+
- runs-on: windows-latest
60+
service-key: SERVICE_KEY_WIN1
61+
- runs-on: windows-2025
62+
service-key: SERVICE_KEY_WIN2
63+
- runs-on: windows-2022
64+
service-key: SERVICE_KEY_WIN3
65+
- runs-on: windows-2019
66+
service-key: SERVICE_KEY_WIN4
67+
runs-on: ${{ matrix.runs-on }}
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Move local action to folder where it can be tested
72+
shell: powershell
73+
run: |
74+
New-Item -Path ".github/actions/test" -ItemType Directory -Force
75+
Copy-Item -Path "action.yml" -Destination ".github/actions/test/action.yml" -Force
76+
77+
- uses: ./.github/actions/test
78+
with:
79+
service-key: ${{ secrets[matrix.service-key] }}
80+
81+
- name: Access a secure resource
82+
shell: powershell
83+
env:
84+
TEST_URL: http://business.prod.beamreachinc.int/
85+
run: |
86+
Write-Host "Calling $env:TEST_URL 🚀"
87+
Invoke-WebRequest -Uri $env:TEST_URL -Verbose
88+
89+
- name: Print client logs
90+
shell: powershell
91+
if: always()
92+
run: Get-Content "$env:PROGRAMDATA\Twingate\logs\twingate.service.log"
93+
94+
- shell: powershell
95+
run: Write-Host "SUCCESS!!! 🤩 This job's status is ${{ job.status }}."

action.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@ inputs:
1010
runs:
1111
using: "composite"
1212
steps:
13-
- name: Install Twingate
13+
- name: Error if unsupported runner.os
14+
if: runner.os != 'Linux' && runner.os != 'Windows'
15+
shell: bash
16+
run: |
17+
echo "Unsupported Runner OS: ${{ runner.os }}"
18+
exit 1
19+
20+
- name: Install Twingate (Linux)
21+
if: runner.os == 'Linux'
1422
shell: bash
1523
run: |
1624
sudo apt update
1725
echo "deb [trusted=yes] https://packages.twingate.com/apt/ /" | sudo tee /etc/apt/sources.list.d/twingate.list
1826
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/twingate.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
1927
sudo apt install -yq twingate
20-
- name: Setup and start Twingate
28+
29+
- name: Setup and start Twingate (Linux)
30+
if: runner.os == 'Linux'
2131
shell: bash
2232
run: |
2333
echo '${{ inputs.service-key }}' | sudo twingate setup --headless -
@@ -55,4 +65,19 @@ runs:
5565
if [ $n -eq $MAX_RETRIES ]; then
5666
echo "Twingate service failed to connect."
5767
exit 1
58-
fi
68+
fi
69+
70+
- name: Install and Start Twingate (Windows)
71+
if: runner.os == 'Windows'
72+
shell: powershell
73+
run: |
74+
Invoke-WebRequest https://api.twingate.com/download/windows?installer=msi -OutFile .\twingate_client.msi
75+
76+
Set-Content .\key.json '${{ inputs.service-key }}'
77+
$key_path = (Get-Item .\key.json | Resolve-Path).ProviderPath
78+
79+
Start-Process msiexec.exe -Wait -ArgumentList "/i twingate_client.msi service_secret=$key_path /quiet"
80+
81+
Start-Service twingate.service
82+
Start-Sleep -Seconds 10
83+
Get-Service twingate.service

0 commit comments

Comments
 (0)