chore(clawhub): 改为本地 pre-push 自动同步 skill
This commit is contained in:
@@ -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
|
||||
@@ -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."
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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."
|
||||
Reference in New Issue
Block a user