Skip to content

Commit 45b6500

Browse files
feat: docs-dispatch workflow → makegov/docs + internal-docs
Installed from mg-tools v0.12.0 docs-dispatch template. Notifies both docs composers via repository_dispatch on push-to-main when docs/** or README.md changes. Requires DOCS_DISPATCH_TOKEN secret with contents:write on makegov/docs + makegov/internal-docs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 35f8d77 commit 45b6500

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Docs dispatch
2+
3+
# Fires on push to the repo's default branch when content that affects
4+
# docs changes. Notifies the appropriate composer repo(s) via
5+
# repository_dispatch so they rebuild without waiting for someone to
6+
# push to the composer.
7+
#
8+
# Two targets:
9+
# - external_updated → makegov/docs (for docs/** minus internal)
10+
# - internal_updated → makegov/internal-docs (for docs/internal/**)
11+
#
12+
# Installed by mg-tools into repos whose docsRole is `coloc-source` or
13+
# `editorial-split-source`. For editorial-split repos (e.g. tango), the
14+
# external dispatch narrows to docs/CHANGELOG.md + README.md (since the
15+
# rest of external docs lives in the composer and gets authored there).
16+
#
17+
# Required secrets:
18+
# DOCS_DISPATCH_TOKEN — GitHub token with contents:write on
19+
# makegov/docs + makegov/internal-docs
20+
#
21+
# Required variables (optional):
22+
# DOCS_TARGET_REPO — override external target (default: makegov/docs)
23+
# INTERNAL_DOCS_TARGET_REPO — override internal target (default: makegov/internal-docs)
24+
#
25+
# On install, mg-tools substitutes the path filters based on docsRole.
26+
27+
on:
28+
push:
29+
branches:
30+
- main
31+
- master
32+
- staging
33+
paths:
34+
- "docs/**"
35+
- "README.md"
36+
workflow_dispatch:
37+
38+
jobs:
39+
dispatch:
40+
runs-on: ubuntu-latest
41+
permissions:
42+
contents: read
43+
steps:
44+
- uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 2
47+
48+
- name: Detect changed paths
49+
id: changes
50+
run: |
51+
set -euo pipefail
52+
base=$(git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD)
53+
all_changed=$(git diff --name-only "$base" HEAD | paste -sd, -)
54+
# External = docs/ files OR README.md, excluding docs/internal/.
55+
external=$(git diff --name-only "$base" HEAD -- 'docs' 'README.md' ':!docs/internal' | paste -sd, -)
56+
# Internal = docs/internal/ files.
57+
internal=$(git diff --name-only "$base" HEAD -- 'docs/internal' | paste -sd, -)
58+
{
59+
echo "changed=$all_changed"
60+
echo "external=$external"
61+
echo "internal=$internal"
62+
echo "has_external=$([ -n "$external" ] && echo true || echo false)"
63+
echo "has_internal=$([ -n "$internal" ] && echo true || echo false)"
64+
} >> "$GITHUB_OUTPUT"
65+
66+
- name: Dispatch to external composer (makegov/docs)
67+
if: steps.changes.outputs.has_external == 'true'
68+
env:
69+
GH_TOKEN: ${{ secrets.DOCS_DISPATCH_TOKEN }}
70+
TARGET: ${{ vars.DOCS_TARGET_REPO || 'makegov/docs' }}
71+
run: |
72+
gh api "repos/$TARGET/dispatches" \
73+
-f event_type=external_updated \
74+
-f "client_payload[source_repo]=${{ github.repository }}" \
75+
-f "client_payload[source_ref]=${{ github.sha }}" \
76+
-f "client_payload[changed_paths]=${{ steps.changes.outputs.external }}"
77+
78+
- name: Dispatch to internal composer (makegov/internal-docs)
79+
if: steps.changes.outputs.has_internal == 'true'
80+
env:
81+
GH_TOKEN: ${{ secrets.DOCS_DISPATCH_TOKEN }}
82+
TARGET: ${{ vars.INTERNAL_DOCS_TARGET_REPO || 'makegov/internal-docs' }}
83+
run: |
84+
gh api "repos/$TARGET/dispatches" \
85+
-f event_type=internal_updated \
86+
-f "client_payload[source_repo]=${{ github.repository }}" \
87+
-f "client_payload[source_ref]=${{ github.sha }}" \
88+
-f "client_payload[changed_paths]=${{ steps.changes.outputs.internal }}"

0 commit comments

Comments
 (0)