Skip to content

Commit 5ff8eff

Browse files
committed
chore(docs): add gh-pages deploy script + root docs:* npm scripts
1 parent 41ba8cf commit 5ff8eff

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

docs/deploy.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
# Deploy docs ke GitHub Pages via branch gh-pages — TANPA GitHub Actions.
3+
# Pakai builder Pages bawaan GitHub (pages-build-deployment) yang tetap jalan
4+
# walau workflow Actions custom gagal (runner:none / billing).
5+
#
6+
# Usage: cd docs && ./deploy.sh
7+
set -euo pipefail
8+
9+
REPO_SLUG="zeative/zaileys"
10+
BRANCH="gh-pages"
11+
DOCS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
ROOT_DIR="$(cd "$DOCS_DIR/.." && pwd)"
13+
WORKTREE="$(mktemp -d -t zaileys-ghp-XXXXXX)"
14+
15+
cleanup() { git -C "$ROOT_DIR" worktree remove "$WORKTREE" --force >/dev/null 2>&1 || true; rm -rf "$WORKTREE"; }
16+
trap cleanup EXIT
17+
18+
echo "▸ Build static export…"
19+
cd "$DOCS_DIR"
20+
npm run build
21+
[ -f out/index.html ] || { echo "✗ out/index.html tidak ada — build gagal"; exit 1; }
22+
touch out/.nojekyll
23+
echo "$(find out -name '*.html' | wc -l | tr -d ' ') halaman"
24+
25+
echo "▸ Publish ke branch $BRANCH"
26+
git -C "$ROOT_DIR" worktree add --detach "$WORKTREE" >/dev/null
27+
cd "$WORKTREE"
28+
git checkout --orphan "$BRANCH" >/dev/null 2>&1
29+
git rm -rf . --quiet >/dev/null 2>&1 || true
30+
cp -R "$DOCS_DIR/out/." .
31+
touch .nojekyll
32+
git add -A
33+
git -c user.email=zaadevofc@gmail.com -c user.name=zeative \
34+
commit -q -m "deploy: docs site ($(find . -name '*.html' | wc -l | tr -d ' ') pages)"
35+
git push -f origin "$BRANCH"
36+
echo " ✓ pushed $(git rev-parse --short HEAD)"
37+
38+
echo "▸ Trigger GitHub Pages build…"
39+
gh api --method PUT "repos/$REPO_SLUG/pages" \
40+
-f build_type=legacy -F "source[branch]=$BRANCH" -F "source[path]=/" >/dev/null 2>&1 || true
41+
gh api --method POST "repos/$REPO_SLUG/pages/builds" >/dev/null
42+
43+
echo "▸ Tunggu build selesai…"
44+
for _ in $(seq 1 20); do
45+
st="$(gh api "repos/$REPO_SLUG/pages/builds/latest" --jq .status 2>/dev/null || echo '?')"
46+
[ "$st" = "built" ] && break
47+
sleep 6
48+
done
49+
echo " ✓ build status: ${st:-unknown}"
50+
51+
echo "▸ Verifikasi…"
52+
code="$(curl -s -o /dev/null -w '%{http_code}' -L https://zeative.github.io/zaileys/ || echo 000)"
53+
echo " https://zeative.github.io/zaileys/ → http=$code"
54+
[ "$code" = "200" ] && echo "✅ Live" || { echo "⚠ Belum 200 — cek beberapa menit lagi (propagasi CDN)"; exit 1; }

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
"test": "vitest run",
4040
"test:watch": "vitest",
4141
"smoke:baileys": "tsx scripts/smoke-baileys.mts",
42+
"docs:dev": "npm --prefix docs run dev",
43+
"docs:build": "npm --prefix docs run build",
44+
"docs:deploy": "bash docs/deploy.sh",
4245
"changeset": "changeset",
4346
"release:version": "changeset version && pnpm install",
4447
"release:publish": "pnpm run build && changeset publish",

0 commit comments

Comments
 (0)