Skip to main content

Forward merged docs(prompts): ... PR events to Alakai

Use this in target repositories that should trigger implementation-agent runs when a prompt PR is merged.

name: Forward merged docs(prompts) PR

on:
pull_request:
types: [closed]

jobs:
forward:
if: >
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.title, 'docs(prompts):')
runs-on: ubuntu-latest
steps:
- name: Build payload
id: payload
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
REPO_FULL_NAME: ${{ github.repository }}
run: |
payload="$(cat <<EOF
{"action":"closed","repository":{"full_name":"$REPO_FULL_NAME"},"pull_request":{"number":$PR_NUMBER,"title":"$PR_TITLE","merged":true,"merge_commit_sha":"$MERGE_SHA","base":{"ref":"$BASE_REF"}}}
EOF
)"
printf 'payload=%s\n' "$payload" >> "$GITHUB_OUTPUT"

- name: Sign payload
id: sign
env:
PAYLOAD: ${{ steps.payload.outputs.payload }}
GITHUB_WEBHOOK_SECRET: ${{ secrets.GITHUB_WEBHOOK_SECRET }}
run: |
digest="$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$GITHUB_WEBHOOK_SECRET" -hex | sed 's/^.* //')"
printf 'signature=sha256=%s\n' "$digest" >> "$GITHUB_OUTPUT"

- name: Send to Alakai
env:
PAYLOAD: ${{ steps.payload.outputs.payload }}
SIGNATURE: ${{ steps.sign.outputs.signature }}
ALAKAI_WEBHOOK_URL: ${{ secrets.ALAKAI_WEBHOOK_URL }}
run: |
curl -sS -X POST "$ALAKAI_WEBHOOK_URL" \
-H "content-type: application/json" \
-H "x-github-event: pull_request" \
-H "x-hub-signature-256: $SIGNATURE" \
--data "$PAYLOAD"

Required secrets in the target repository:

  • GITHUB_WEBHOOK_SECRET (same value configured in Alakai)
  • ALAKAI_WEBHOOK_URL (for example https://alakai.example.com/github/webhook)