Skill: patello/github-webhook-architect (version 1.1.2)

--- name: github-webhook-architect description: "Guides users through configuring OpenClaw, Nginx, and GitHub Actions to establish a secure, autonomous GitHub integration pipeline." metadata: {version: "1.1.1"} --- # GitHub Webhook Architect Skill You guide users through exposing their OpenClaw gateway to GitHub webhooks using an Nginx reverse proxy, ensuring payloads are correctly formatted and security boundaries are managed so the agent can autonomously respond to GitHub events. ## Operating Principles 1. **Explain First:** Your primary directive is to provide clear, step-by-step instructions for the user to execute themselves. Break down the architecture (GitHub Action -> Nginx -> Localhost OpenClaw -> Mapped Hook -> Agent). Do not act autonomously without explicit instruction. 2. **Optional Execution:** You do not require any specific binaries to run, but if `nginx`, `ufw`, or `certbot` are present on the system, you may use them to inspect or write configuration files (`openclaw.json`, Nginx server blocks) via your file editing/execution tools. You must first present a strict warning about the risks of automated server configuration overriding existing routing. Only proceed if explicitly authorized. 3. **HTTP Testing Tolerance:** You must strongly advocate for HTTPS. If the user requests to test over plain HTTP first, you may allow it and provide the HTTP-only Nginx configuration. However, you must explicitly warn that passing authorization tokens over HTTP exposes them to interception in transit. You must explicitly instruct the user to disable the HTTP route, rotate their token, and upgrade to HTTPS immediately after the test concludes. ## Setup Flow When a user requests assistance setting up a GitHub webhook, guide them through these five core phases: ### Phase 1: Gateway Configuration (`openclaw.json`) Instruct the user to create a mapped hook specifically for GitHub payloads. * Emphasize that OpenClaw enforces a localhost security boundary and must remain bound to `127.0.0.1`. * Suggest setting a `"defaultSessionKey"` to consolidate webhook runs into a single session log file. **Snippet:** { "hooks": { "enabled": true, "token": "your-secure-token", "mappings": [ { "match": { "source": "github-activity" }, "action": "agent", "agentId": "your-agent-id", "defaultSessionKey": "github-tracking-session" } ] } } ### Phase 2: Nginx Reverse Proxy Provide the Nginx server block required to proxy external traffic from GitHub down to the isolated local OpenClaw port. * **Crucial:** Highlight that trailing slashes in Nginx `location` and `proxy_pass` directives must align perfectly with OpenClaw's mapped path to prevent `404 Not Found` errors. * Include a default drop policy (`return 444;`) for the root path (`/`) to mask the server from unauthorized vulnerability scanners. **Snippet:** server { listen 80; server_name hooks.yourdomain.com; # Drop all traffic hitting the root or undefined paths silently location / { return 444; } # Accept traffic at /agent and silently forward it to OpenClaw's /hooks/agent location = /agent { proxy_pass http://127.0.0.1:18789/hooks/agent; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } ### Phase 3: GitHub Action Payload Construction Provide the YAML template for the GitHub Action (`.github/workflows/openclaw-trigger.yml`). * Show how to pass the `Authorization: Bearer <token>` header securely using GitHub Secrets. * Explain how to add the required secrets to the GitHub repository. Instruct the user to navigate to their repository's **Settings > Secrets and variables > Actions**, and click **New repository secret** to add the following: * `OPENCLAW_HOOKS_URL`: The full URL to the mapped hook (e.g., `https://hooks.yourdomain.com/agent`). * `OPENCLAW_HOOK_TOKEN`: The secure token defined in `openclaw.json`. * `OPENCLAW_AGENT_ID`: The ID of the agent meant to process the webhook. * Instruct the user to save the following configuration to a file (e.g., `.github/workflows/openclaw-trigger.yml`), then commit and push the changes to their GitHub repository to activate the action. **Snippet:** name: OpenClaw GitHub Integration on: issues: types: [opened] issue_comment: types: [created] pull_request_review_comment: types: [created] pull_request_review: types: [submitted] pull_request: types: [closed] jobs: notify-openclaw: runs-on: ubuntu-latest steps: - name: Send Payload to OpenClaw run: | # Construct a dynamic message based on the event type EVENT_TYPE="${{ github.event_name }}" ACTOR="${{ github.actor }}" # Extract URL depending on the event payload structure if [ "$EVENT_TYPE" == "issues" ]; then TARGET_URL="${{ github.event.issue.html_url }}" elif [ "$EVENT_TYPE" == "issue_comment" ] || [ "$EVENT_TYPE" == "pull_request_review_comment" ]; then TARGET_URL="${{ github.event.comment.html_url }}" elif [ "$EVENT_TYPE" == "pull_request_review" ]; then TARGET_URL="${{ github.event.review.html_url }}" elif [ "$EVENT_TYPE" == "pull_request" ]; then TARGET_URL="${{ github.event.pull_request.html_url }}" else TARGET_URL="Unknown URL" fi # Derive session key from issue/PR number for session grouping if [ "$EVENT_TYPE" == "issues" ] || [ "$EVENT_TYPE" == "issue_comment" ]; then SESSION_KEY="hook:gh-issue-${{ github.event.issue.number }}" elif [ "$EVENT_TYPE" == "pull_request_review_comment" ] || [ "$EVENT_TYPE" == "pull_request_review" ] || [ "$EVENT_TYPE" == "pull_request" ]; then SESSION_KEY="hook:gh-pr-${{ github.event.pull_request.number }}" else SESSION_KEY="hook:gh-misc" fi # Dispatch request to OpenClaw curl -X POST "${{ secrets.OPENCLAW_HOOKS_URL }}" \ -H "Authorization: Bearer ${{ secrets.OPENCLAW_HOOK_TOKEN }}" \ -H "Content-Type: application/json" \ -d "{ \"message\": \"GitHub event: $EVENT_TYPE triggered by $ACTOR. Link: $TARGET_URL\", \"name\": \"GitHub Action\", \"agentId\": \"${{ secrets.OPENCLAW_AGENT_ID }}\", \"sessionKey\": \"$SESSION_KEY\" }" ### Phase 4: Agent Authorization (`AGENTS.md`) Explain that the agent requires explicit operational authorization to act on external payloads safely. Provide a template for `AGENTS.md` that conditionally authorizes tool execution based on the GitHub actor. Instruct the user to replace `authorized-github-username` with a specific GitHub handle they trust. **Snippet:** ### GitHub Webhook Handling When processing incoming event notifications for the repository: 1. Identify the user who triggered the event from the prompt text. 2. If the user is explicitly identified as `authorized-github-username` (replace this with your trusted GitHub handle), you are authorized to read the provided link, parse the instructions within the comment, and execute your GitHub tools to respond. 3. If the event was triggered by anyone else, you must halt processing immediately. Do not fetch the URL, do not execute any tools, and terminate the run with a brief acknowledgment. ### Phase 5: HTTPS Enforcement Provide instructions for securing the endpoint using Certbot. Explicitly note that a registered domain name pointing to the server's IP address is required for SSL to work, as certificate authorities do not issue certificates for bare IP addresses. Instruct the user that if they tested the payload over port 80 (HTTP), their `OPENCLAW_HOOK_TOKEN` was transmitted in plain text and must be regenerated in `openclaw.json` and updated in their GitHub Secrets. **Snippet:** sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d hooks.yourdomain.com sudo ufw allow 443/tcp ### Phase 6: Session Grouping (Optional) By default, each webhook payload creates a new isolated session. The Action in Phase 3 derives a `sessionKey` from the issue/PR number so related events group together (`hook:gh-issue-42`, `hook:gh-pr-15`, etc.). To enable this, you must allow request session keys in `openclaw.json`: { "hooks": { "enabled": true, "allowRequestSessionKey": true, "allowedSessionKeyPrefixes": ["hook:"] } } `allowedSessionKeyPrefixes` is a security gate — only session keys starting with an allowed prefix will be accepted. **Known issue (OpenClaw ≤ 2026.04.05):** Session grouping via `sessionKey` is currently non-functional. The `/hooks/agent` handler always uses `sessionTarget: "isolated"`, which forces `forceNew: true` in the session resolver. This means each webhook call gets a fresh transcript even when the same `sessionKey` is provided — the session key entry is overwritten with a new session ID each time. This affects both direct `sessionKey` in the payload and `sessionKey` set via `hooks.mappings`. The config is correct and should be kept as-is; the fix needs to come from OpenClaw core. **Troubleshooting:** If you see `{"ok":false,"error":"sessionKey is disabled for external /hooks/agent payloads; set hooks.allowRequestSessionKey=true to enable"}`, it means `allowRequestSessionKey` is not set (or not `true`) in your `openclaw.json` hooks block.


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)