From 4794ab1d9a9e520f76b7075bc6d4f6a12857eed3 Mon Sep 17 00:00:00 2001 From: thxforall <113906780+thxforall@users.noreply.github.com> Date: Thu, 21 May 2026 16:17:36 +0900 Subject: [PATCH] ci(github): dispatch git events to decoded-docs vault Trigger decoded-docs repository_dispatch (git-event) when a PR is merged into main/dev, a release is published, or via manual workflow_dispatch. Pairs with the vault-sync workflow in decoded-docs to record changelog entries automatically. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/dispatch-docs-event.yml | 92 +++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/dispatch-docs-event.yml diff --git a/.github/workflows/dispatch-docs-event.yml b/.github/workflows/dispatch-docs-event.yml new file mode 100644 index 00000000..9c23a916 --- /dev/null +++ b/.github/workflows/dispatch-docs-event.yml @@ -0,0 +1,92 @@ +name: Dispatch git events to docs vault + +on: + pull_request: + types: [closed] + branches: [main, dev] + release: + types: [published] + workflow_dispatch: + inputs: + type: + description: "Event type" + required: true + default: "manual" + message: + description: "Event message" + required: true + default: "Manual dispatch from monorepo" + +permissions: + contents: read + +jobs: + dispatch: + if: >- + github.event_name != 'pull_request' || + github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Build payload + id: payload + shell: bash + env: + EVENT_NAME: ${{ github.event_name }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_BASE: ${{ github.event.pull_request.base.ref }} + PR_URL: ${{ github.event.pull_request.html_url }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_NAME: ${{ github.event.release.name }} + RELEASE_URL: ${{ github.event.release.html_url }} + MANUAL_TYPE: ${{ github.event.inputs.type }} + MANUAL_MESSAGE: ${{ github.event.inputs.message }} + run: | + set -euo pipefail + case "$EVENT_NAME" in + pull_request) + type="pr-merge-${PR_BASE}" + message="PR #${PR_NUMBER} merged into ${PR_BASE}: ${PR_TITLE} (${PR_URL})" + ;; + release) + type="release" + message="Release ${RELEASE_TAG} — ${RELEASE_NAME} (${RELEASE_URL})" + ;; + workflow_dispatch) + type="${MANUAL_TYPE}" + message="${MANUAL_MESSAGE}" + ;; + *) + type="unknown" + message="Unhandled event: ${EVENT_NAME}" + ;; + esac + { + echo "type=${type}" + echo "message<> "$GITHUB_OUTPUT" + + - name: Trigger decoded-docs repository_dispatch + env: + GH_TOKEN: ${{ secrets.DOCS_DISPATCH_TOKEN }} + EVENT_TYPE: ${{ steps.payload.outputs.type }} + EVENT_MESSAGE: ${{ steps.payload.outputs.message }} + run: | + set -euo pipefail + payload=$(jq -nc \ + --arg type "$EVENT_TYPE" \ + --arg message "$EVENT_MESSAGE" \ + '{event_type: "git-event", client_payload: {type: $type, message: $message}}') + + if ! gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + /repos/decodedcorp/decoded-docs/dispatches \ + --input - <<<"$payload"; then + echo "::warning::Failed to dispatch git-event to decoded-docs." + exit 0 + fi + + echo "Dispatched git-event (${EVENT_TYPE}) to decoded-docs."