diff --git a/.github/workflows/clawhub-sync.yml b/.github/workflows/clawhub-sync.yml deleted file mode 100644 index 3dd2fa0..0000000 --- a/.github/workflows/clawhub-sync.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: ClawHub Sync - -on: - push: - branches: - - '**' - workflow_dispatch: - -permissions: - contents: read - -jobs: - sync-skills: - name: Sync skills to ClawHub - runs-on: ubuntu-latest - env: - CLAWHUB_TOKEN: ${{ secrets.CLAWHUB_TOKEN }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup pnpm - uses: pnpm/action-setup@v4 - with: - version: 9 - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: pnpm - - - name: Validate CLAWHUB_TOKEN - run: | - if [ -z "${CLAWHUB_TOKEN}" ]; then - echo "CLAWHUB_TOKEN is not set. Add it in repository secrets." - exit 1 - fi - - - name: Login to ClawHub - run: pnpm dlx clawhub@latest login --token "${CLAWHUB_TOKEN}" --no-browser - - - name: Sync all local skills - run: | - pnpm dlx clawhub@latest sync --all --root ./skills diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100644 index 0000000..f2a2583 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,8 @@ +if [ "${SKIP_CLAWHUB_SYNC:-0}" = "1" ]; then + echo "Skipping ClawHub sync (SKIP_CLAWHUB_SYNC=1)" + exit 0 +fi + +pnpm run clawhub:sync || { + echo "ClawHub sync failed. Push continues. Run 'pnpm run clawhub:sync' manually after fixing login/network." +} diff --git a/README.md b/README.md index d0c6076..c7b8cad 100644 --- a/README.md +++ b/README.md @@ -141,13 +141,23 @@ This repo includes a dedicated OpenClaw skill at: - `skills/agent-browser-stealth/SKILL.md` -GitHub Actions auto-syncs skills to ClawHub on every push via: +Local git `pre-push` hook auto-syncs skills before every push: -- `.github/workflows/clawhub-sync.yml` +- `.husky/pre-push` -> `pnpm run clawhub:sync` -Required repository secret: +Manual sync command (same logic as hook): -- `CLAWHUB_TOKEN`: API token used by `clawhub login --token ...` +```bash +pnpm run clawhub:sync +``` + +This uses your existing local ClawHub login session (no GitHub secret required). + +Temporarily skip auto-sync for one push: + +```bash +SKIP_CLAWHUB_SYNC=1 git push +``` ## License diff --git a/package.json b/package.json index 38791f2..abfa681 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "test": "vitest run", "test:watch": "vitest", "postinstall": "node scripts/postinstall.js", + "clawhub:sync": "bash scripts/clawhub-sync.sh", "sync:upstream": "bash scripts/sync-upstream.sh", "sync:upstream:push": "bash scripts/sync-upstream.sh --push", "changeset": "changeset", diff --git a/scripts/clawhub-sync.sh b/scripts/clawhub-sync.sh new file mode 100644 index 0000000..c9e7228 --- /dev/null +++ b/scripts/clawhub-sync.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +cd "$ROOT_DIR" +SKILL_NAME="agent-browser-stealth" + +if ! command -v pnpm >/dev/null 2>&1; then + echo "pnpm is required for ClawHub sync" + exit 1 +fi + +if [ ! -f "skills/${SKILL_NAME}/SKILL.md" ]; then + echo "Missing skill file: skills/${SKILL_NAME}/SKILL.md" + exit 1 +fi + +# Sync only this fork-owned skill to avoid permission errors on other skills. +TMP_DIR="$(mktemp -d)" +trap 'rm -rf "$TMP_DIR"' EXIT +mkdir -p "$TMP_DIR/skills" +cp -R "skills/${SKILL_NAME}" "$TMP_DIR/skills/${SKILL_NAME}" + +echo "Syncing local skill '${SKILL_NAME}' to ClawHub..." +cd "$TMP_DIR" +pnpm dlx clawhub@latest sync --all --root ./skills +echo "ClawHub sync completed."