Skip to content

Commit 68fd9f7

Browse files
authored
fix: Fix installation + Add CI test for action (#13)
1 parent 4493ffc commit 68fd9f7

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: test
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'main'
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Move local action to folder where it can be tested
16+
shell: bash
17+
run: |
18+
mkdir -p .github/actions/test
19+
cp action.yml .github/actions/test/action.yml
20+
21+
- uses: ./.github/actions/test
22+
with:
23+
service-key: ${{ secrets.SERVICE_KEY }}
24+
25+
- name: (optional) Twingate logs
26+
run: journalctl -u twingate
27+
28+
- name: (optional) Twingate status
29+
run: twingate status
30+
31+
- name: Access a secure resource
32+
env:
33+
TEST_URL: http://business.prod.beamreachinc.int/
34+
run: |
35+
echo Calling $TEST_URL 🚀
36+
curl -v $TEST_URL
37+
38+
- run: echo "SUCCESS!!! 🤩 This job's status is ${{ job.status }}."

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.secrets

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,13 @@ There are two common use cases:
1818
# Required
1919
service-key: ${{ secrets.EXAMPLE_SERVICE_KEY_SECRET_NAME }}
2020
```
21+
22+
23+
# Development
24+
25+
To run action locally to debug you can use `act` (`brew install act`):
26+
```
27+
act -j test -s SERVICE_KEY --container-options "--cap-add NET_ADMIN --device /dev/net/tun"
28+
```
29+
30+
It'll ask for `SERVICE_KEY` value interactively.

action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,36 @@ runs:
1313
- name: Install Twingate
1414
shell: bash
1515
run: |
16+
sudo apt update
1617
echo "deb [trusted=yes] https://packages.twingate.com/apt/ /" | sudo tee /etc/apt/sources.list.d/twingate.list
1718
sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/twingate.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
1819
sudo apt install -yq twingate
1920
- name: Setup and start Twingate
2021
shell: bash
2122
run: |
22-
echo '${{ inputs.service-key }}' | sudo twingate setup --headless=-
23+
echo '${{ inputs.service-key }}' | sudo twingate setup --headless -
2324
MAX_RETRIES=5
2425
WAIT_TIME=5
2526
n=0
2627
2728
while [ $n -lt $MAX_RETRIES ]; do
2829
echo "Starting Twingate service..."
30+
set +xe
2931
sudo twingate start
3032
3133
echo "Waiting $WAIT_TIME seconds for Twingate service to start..."
3234
sleep $WAIT_TIME
3335
34-
status=$(sudo twingate status)
36+
status=$(twingate status)
37+
echo "Twingate service status: '$status'"
3538
3639
if [ "$status" = "online" ]; then
3740
echo "Twingate service is connected."
41+
twingate resources
3842
break
3943
else
4044
sudo twingate stop
45+
journalctl -u twingate --no-pager
4146
fi
4247
4348
# Increment the retry counter and wait time

0 commit comments

Comments
 (0)