Skip to content

Commit 9dfd30d

Browse files
committed
good
1 parent 31fe019 commit 9dfd30d

4 files changed

Lines changed: 157 additions & 33 deletions

File tree

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM debian:bookworm-slim
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
sudo \
7+
jq \
8+
vim-common \
9+
gnupg \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
# Add a non-root user for BrowserBox
13+
RUN useradd -m -s /bin/bash browserbox && \
14+
echo "browserbox ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
15+
16+
USER browserbox
17+
WORKDIR /home/browserbox
18+
19+
# Install BrowserBox using full-install
20+
# BBX_TEST_AGREEMENT=true skips prompts
21+
# BBX_FULL_INSTALL=true triggers full-install
22+
# BBX_INSTALL_HOSTNAME="localhost"
23+
# BBX_INSTALL_EMAIL="actions@browserbox.io"
24+
# INSTALL_DOC_VIEWER="false" skips doc viewer
25+
RUN curl -fsSL https://browserbox.io/install.sh | \
26+
BBX_TEST_AGREEMENT="true" \
27+
BBX_FULL_INSTALL="true" \
28+
BBX_INSTALL_HOSTNAME="localhost" \
29+
BBX_INSTALL_EMAIL="actions@browserbox.io" \
30+
INSTALL_DOC_VIEWER="false" \
31+
bash
32+
33+
# Ensure bbx is in PATH
34+
ENV PATH="/home/browserbox/.local/bin:${PATH}"
35+
36+
# Expose the default BrowserBox port
37+
EXPOSE 8080
38+
39+
# Default command
40+
CMD ["bbx", "status"]

README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ On runners, the action defaults to a minimal runtime footprint:
1818
`browserbox-action` v1 is intentionally narrow:
1919

2020
- Linux runners only
21-
- `tunnel: none`
22-
- `tunnel: cloudflare` (Public login link)
23-
- `tunnel: tor`
24-
- ZeroTier is intentionally excluded from v1
21+
- `tunnel: cloudflare` (Default - Public login link)
22+
- `tunnel: tor` (Onion address)
23+
- `tunnel: none` (Local runner only)
2524

2625
## Quick start
2726

@@ -40,7 +39,6 @@ jobs:
4039
uses: BrowserBox/browserbox-action@v1
4140
with:
4241
license-key: ${{ secrets.BROWSERBOX_LICENSE_KEY }}
43-
tunnel: cloudflare
4442
timeout: 60 # Stay alive for 60 minutes
4543
```
4644
@@ -49,13 +47,43 @@ jobs:
4947
- **Interactive Login Link:** Like `tmate`, the action prints the login link in a loop to the console until the timeout is reached or the job is cancelled.
5048
- **Configurable Timeout:** Control how long the session stays active (default 30m, up to 150m).
5149
- **Step Summary:** Automatically adds the login link and base URL to the GitHub Actions Job Summary.
50+
- **Automated Verification:** The action includes a built-in background smoke test to confirm the public accessibility of your tunnel.
51+
52+
## Example Usages
53+
54+
### Public Cloudflare Tunnel (Default)
55+
Ideal for quick demos or ephemeral browsing sessions.
56+
```yaml
57+
- uses: BrowserBox/browserbox-action@v1
58+
with:
59+
license-key: ${{ secrets.BBX_LICENSE_KEY }}
60+
tunnel: cloudflare
61+
```
62+
63+
### Tor Network Tunnel
64+
Generates a `.onion` address for maximum privacy.
65+
```yaml
66+
- uses: BrowserBox/browserbox-action@v1
67+
with:
68+
license-key: ${{ secrets.BBX_LICENSE_KEY }}
69+
tunnel: tor
70+
```
71+
72+
### Local Runner (No Tunnel)
73+
Useful for automated testing where subsequent steps interact with the browser via `localhost:8080`.
74+
```yaml
75+
- uses: BrowserBox/browserbox-action@v1
76+
with:
77+
license-key: ${{ secrets.BBX_LICENSE_KEY }}
78+
tunnel: none
79+
```
5280

5381
## Inputs
5482

5583
| Input | Required | Default | Notes |
5684
| --- | --- | --- | --- |
5785
| `license-key` | Yes | none | BrowserBox license key from [browserbox.io](https://browserbox.io) |
58-
| `tunnel` | No | `none` | `none`, `cloudflare`, or `tor` |
86+
| `tunnel` | No | `cloudflare` | `none`, `cloudflare`, or `tor` |
5987
| `timeout` | No | `30` | Maximum run time in minutes (max 150) |
6088
| `port` | No | `8080` | Main BrowserBox service port |
6189
| `service-mode` | No | `minimal` | `minimal` runs only `bb-main`; `full` runs all BrowserBox services |

run-browserbox.sh

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,34 @@ open_url() {
239239
fi
240240
}
241241

242+
check_link_accessible() {
243+
local link="$1"
244+
local base_url="${link%/login?token=*}"
245+
local response
246+
local out_file
247+
out_file="$(mktemp)"
248+
249+
if ! command -v curl >/dev/null 2>&1; then
250+
rm -f "$out_file"
251+
return 0
252+
fi
253+
254+
response=$(curl -s -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" --max-time 10 -w "%{http_code}" "$base_url" -o "$out_file" || echo "CURL_FAILED")
255+
256+
if [[ "$response" =~ ^(200|403)$ ]]; then
257+
if grep -qi "BrowserBox" "$out_file" 2>/dev/null; then
258+
rm -f "$out_file"
259+
return 0
260+
fi
261+
elif [[ "$response" =~ ^(302|401)$ ]]; then
262+
rm -f "$out_file"
263+
return 0
264+
fi
265+
266+
rm -f "$out_file"
267+
return 1
268+
}
269+
242270
find_latest_dispatch_run() {
243271
local repo="$1"
244272
local workflow="$2"
@@ -329,8 +357,11 @@ wait_for_login_link() {
329357
)"
330358

331359
if [[ -n "$link" ]]; then
332-
printf '%s\n' "$link"
333-
return 0
360+
if check_link_accessible "$link"; then
361+
printf '%s\n' "$link"
362+
return 0
363+
fi
364+
log "found link on issue #${issue_number}, but it is not yet accessible; still waiting..."
334365
fi
335366

336367
status="$(gh run view "$run_id" --repo "$repo" --json status,conclusion --jq '.status + ":" + (.conclusion // "")' 2>/dev/null || true)"

scripts/run-browserbox.sh

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,37 @@ base_url_from_login_link() {
4040
printf '%s' "$1" | sed 's#/login?token=.*##'
4141
}
4242

43+
check_link_accessible() {
44+
local link="$1"
45+
local base_url
46+
base_url="$(base_url_from_login_link "$link")"
47+
local response
48+
local out_file
49+
out_file="$(mktemp)"
50+
51+
response=$(curl -s -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" --max-time 10 -w "%{http_code}" "$base_url" -o "$out_file" || echo "CURL_FAILED")
52+
53+
if [[ "$response" =~ ^(200|302|401)$ ]]; then
54+
if [[ "$response" == "200" ]]; then
55+
if grep -qi "BrowserBox" "$out_file" 2>/dev/null; then
56+
rm -f "$out_file"
57+
return 0
58+
fi
59+
else
60+
rm -f "$out_file"
61+
return 0
62+
fi
63+
elif [[ "$response" == "403" ]]; then
64+
if grep -qi "BrowserBox" "$out_file" 2>/dev/null; then
65+
rm -f "$out_file"
66+
return 0
67+
fi
68+
fi
69+
70+
rm -f "$out_file"
71+
return 1
72+
}
73+
4374
ensure_gh_token() {
4475
if [[ -z "${GH_TOKEN:-}" && -n "${GITHUB_TOKEN:-}" ]]; then
4576
export GH_TOKEN="$GITHUB_TOKEN"
@@ -206,20 +237,24 @@ case "$tunnel" in
206237
# cf-run can spend time in setup/certification, local readiness retries,
207238
# and up to three Cloudflare URL/verification attempts.
208239
login_link=""
240+
echo "Waiting for verified Cloudflare tunnel URL..."
209241
for ((i = 0; i < cloudflare_link_timeout_seconds; i++)); do
210242
candidate="$(extract_cloudflare_login_link "$login_link_file")"
211243
if [[ -z "$candidate" ]]; then
212244
candidate="$(extract_cloudflare_login_link "$run_log")"
213245
fi
214246
if [[ -n "$candidate" ]]; then
215-
login_link="$candidate"
216-
break
247+
if check_link_accessible "$candidate"; then
248+
login_link="$candidate"
249+
echo "Verified Cloudflare tunnel URL: $login_link"
250+
break
251+
fi
217252
fi
218253
if ! kill -0 "$cf_pid" 2>/dev/null; then
219254
cat "$run_log" >&2
220255
fail "bbx cf-run exited before producing a tunnel URL."
221256
fi
222-
sleep 1
257+
sleep 2
223258
done
224259

225260
if [[ -z "$login_link" ]]; then
@@ -276,34 +311,22 @@ echo "--------------------------------------------------------------------------
276311

277312
# Background smoke test for public accessibility
278313
(
279-
echo "[Smoke Test] Waiting for tunnel to propagate (up to 2 minutes)..."
314+
echo "[Smoke Test] Verifying tunnel propagation..."
280315
MAX_SMOKE_ATTEMPTS=12
281316
SMOKE_ATTEMPT=1
282317
SMOKE_SUCCESS=false
283-
318+
284319
while (( SMOKE_ATTEMPT <= MAX_SMOKE_ATTEMPTS )); do
285-
sleep 10
286-
echo "[Smoke Test Attempt $SMOKE_ATTEMPT/$MAX_SMOKE_ATTEMPTS] Checking $base_url ..."
287-
# Try with verbose output to diagnose 403 or other issues
288-
RESPONSE=$(curl -s -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" --max-time 10 -w "%{http_code}" "$base_url" -o /tmp/smoke_out.html || echo "CURL_FAILED")
289-
290-
echo "[Smoke Test] Response code: $RESPONSE"
291-
292-
if [[ "$RESPONSE" =~ ^(200|302|401)$ ]]; then
320+
if check_link_accessible "$login_link"; then
293321
echo "[Smoke Test] SUCCESS: BrowserBox is accessible via tunnel."
294322
SMOKE_SUCCESS=true
295323
break
296-
elif [[ "$RESPONSE" == "403" ]]; then
297-
echo "[Smoke Test] Received 403. This might be Cloudflare WAF or Bot Protection. Checking content..."
298-
if grep -qi "BrowserBox" /tmp/smoke_out.html; then
299-
echo "[Smoke Test] SUCCESS: Found 'BrowserBox' in 403 response body. It is reachable!"
300-
SMOKE_SUCCESS=true
301-
break
302-
fi
303324
fi
325+
echo "[Smoke Test Attempt $SMOKE_ATTEMPT/$MAX_SMOKE_ATTEMPTS] Not yet accessible..."
304326
(( SMOKE_ATTEMPT++ ))
327+
sleep 10
305328
done
306-
329+
307330
if [[ "$SMOKE_SUCCESS" != "true" ]]; then
308331
echo "[Smoke Test] WARNING: BrowserBox might not be publicly accessible yet (or check failed)."
309332
fi
@@ -320,10 +343,12 @@ while (( $(date +%s) < end_time )); do
320343
if [[ "$tunnel" == "cloudflare" ]]; then
321344
refreshed_link="$(extract_cloudflare_login_link "$login_link_file")"
322345
if [[ -n "$refreshed_link" && "$refreshed_link" != "$login_link" ]]; then
323-
login_link="$refreshed_link"
324-
base_url="$(base_url_from_login_link "$login_link")"
325-
echo "::notice title=BrowserBox Login Link Updated::$login_link"
326-
broadcast_login_link "BrowserBox login link updated"
346+
if check_link_accessible "$refreshed_link"; then
347+
login_link="$refreshed_link"
348+
base_url="$(base_url_from_login_link "$login_link")"
349+
echo "::notice title=BrowserBox Login Link Updated::$login_link"
350+
broadcast_login_link "BrowserBox login link updated"
351+
fi
327352
fi
328353
fi
329354
echo "[$(date +%T)] BrowserBox is active. Login at: $login_link"

0 commit comments

Comments
 (0)