Skip to content

Commit 2124958

Browse files
committed
Feature: ngrok key is optional now
1 parent bf28a68 commit 2124958

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

.github/workflows/ssh.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
- '5h45m'
1818
NGROK_AUTH_TOKEN:
1919
description: 'ngrok API auth token'
20-
required: true
20+
required: false
2121
default: ''
2222
SWAP_SIZE:
2323
description: 'add Swap/virtual RAM in GBs'
@@ -43,6 +43,7 @@ jobs:
4343
uses: actions/checkout@v4
4444

4545
- name: Prepare variables
46+
id: prepare
4647
env:
4748
NGROK_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
4849
run: |
@@ -53,6 +54,12 @@ jobs:
5354
fi
5455
echo NGROK_TOKEN=$NGROK_TOKEN >> $GITHUB_ENV
5556
57+
if [ -n "$NGROK_TOKEN" ] && [ "$NGROK_TOKEN" != "null" ]; then
58+
echo "ngrok_token_not_empty=true" >> $GITHUB_OUTPUT
59+
else
60+
echo "ngrok_token_not_empty=false" >> $GITHUB_OUTPUT
61+
fi
62+
5663
- name: Clean-up
5764
if: ${{ github.event.inputs.START_CLEAN_UP == 'true' }}
5865
uses: rokibhasansagar/slimhub_actions@main
@@ -64,7 +71,9 @@ jobs:
6471
swap-size-gb: ${{ github.event.inputs.SWAP_SIZE }}
6572

6673
- name: Install ngrok
74+
if: ${{ steps.prepare.outputs.ngrok_token_not_empty == 'true' }}
6775
run: |
76+
echo "test: $NGROK_TOKEN"
6877
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null
6978
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list
7079
sudo apt update && sudo apt install -y ngrok
@@ -116,6 +125,7 @@ jobs:
116125
117126
118127
- name: Start ngrok
128+
if: ${{ steps.prepare.outputs.ngrok_token_not_empty == 'true' }}
119129
run: |
120130
chmod +x gen_ngrok_config.sh
121131
./gen_ngrok_config.sh "$NGROK_TOKEN"
@@ -146,4 +156,5 @@ jobs:
146156
5h45m) SLEEP_TIME=$((5 * 3600 + 45 * 60)) ;;
147157
esac
148158
echo "⏳ Keeping SSH session alive for $RAW_TIME ($SLEEP_TIME seconds)"
159+
echo "🔗 Updates available at: https://github.com/chunix64/github-action-ssh"
149160
sleep "$SLEEP_TIME" || true

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# 🚀 Ubuntu Linux SSH via ngrok GitHub Action
22

3-
This GitHub Action sets up an Ubuntu Linux environment with SSH access tunneled through **ngrok**, optionally serving files with **miniserve**, cleaning up disk space, and adding swap memory.
3+
This GitHub Action sets up an Ubuntu Linux environment with SSH access tunneled through **ngrok**, **cloudflared**, serving files with **miniserve**, cleaning up disk space, and adding swap memory.
44

55
---
66

77
## ⚙️ Features
88

9-
- 🔐 Secure SSH access via ngrok TCP tunnel
9+
- 📡 SSH access via ngrok and cloudflared tunnel
1010
- 🌐 Optional HTTP file server with miniserve
1111
- 🧹 Optional disk cleanup to free up space (~27GB → 68GB)
12-
- 💾 Optional swap/virtual RAM extension (default: 4GB → 24GB)
12+
- 💾 Optional swap/virtual RAM extension
1313
- ⏳ SSH session auto-kept alive up to 6 hours
1414

1515
---
@@ -22,7 +22,7 @@ This GitHub Action sets up an Ubuntu Linux environment with SSH access tunneled
2222
| `NGROK_AUTH_TOKEN` | String || Your ngrok API auth token (required) |
2323
| `START_MINISERVE` | Boolean | true | Enable HTTP file server for file sharing |
2424
| `START_CLEAN_UP` | Boolean | true | Run disk cleanup to free space (~4 min runtime) |
25-
| `SWAP_SPACE` | String | 20 | Add swap space / virtual RAM in GBs |
25+
| `SWAP_SPACE` | String | 16 | Add swap space / virtual RAM in GBs |
2626

2727
---
2828

@@ -40,7 +40,7 @@ This GitHub Action sets up an Ubuntu Linux environment with SSH access tunneled
4040
TUNNEL: <url>
4141
```
4242

43-
4. Connect via SSH or use miniserve for file sharing.
43+
5. Connect via SSH or use miniserve for file sharing.
4444

4545
---
4646

@@ -60,6 +60,8 @@ TUNNEL: <url>
6060
- You can cancel the workflow anytime, but SSH session ends when the runner stops.
6161
- `START_MINISERVE` serves your entire filesystem (beware of sensitive data).
6262
- Requires a valid ngrok auth token to create tunnels.
63+
- Why 5h45m instead of 6h?
64+
Answer: The server is terminated before GitHub does, ensuring the workflow completes successfully and normalizes GitHub activity.
6365

6466
---
6567

@@ -69,7 +71,7 @@ TUNNEL: <url>
6971
---
7072

7173
## 📝Todos
72-
- Support Cloudflared and other tunnels
74+
- Support Cloudflared and other tunnels (Done: 50%)
7375
- Support terminal/SSH over web, especially mobile
7476
- Support macOS and Windows SSH
7577
- Add more documentation

0 commit comments

Comments
 (0)