|
| 1 | +name: Docs dispatch |
| 2 | + |
| 3 | +# Fires on push to main when content that affects the published docs site |
| 4 | +# changes (docs/, README, CHANGELOG, or the public source of any workspace |
| 5 | +# crate). Notifies makegov/docs via repository_dispatch so the docs site |
| 6 | +# rebuilds without waiting for someone to push to the composer. |
| 7 | +# |
| 8 | +# tango-rust is a `coloc-source` repo: its docs/ folder is the authoritative |
| 9 | +# source for the Rust SDK pages on docs.makegov.com. |
| 10 | +# |
| 11 | +# Required secrets: |
| 12 | +# DOCS_DISPATCH_TOKEN — GitHub token with contents:write on makegov/docs. |
| 13 | +# |
| 14 | +# Required variables (optional): |
| 15 | +# DOCS_TARGET_REPO — override the dispatch target (default: makegov/docs). |
| 16 | + |
| 17 | +on: |
| 18 | + push: |
| 19 | + branches: |
| 20 | + - main |
| 21 | + paths: |
| 22 | + - "docs/**" |
| 23 | + - "README.md" |
| 24 | + - "CHANGELOG.md" |
| 25 | + - "crates/*/src/**" |
| 26 | + workflow_dispatch: |
| 27 | + |
| 28 | +jobs: |
| 29 | + dispatch: |
| 30 | + runs-on: ubuntu-latest |
| 31 | + permissions: |
| 32 | + contents: read |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + fetch-depth: 2 |
| 37 | + |
| 38 | + - name: Detect changed paths |
| 39 | + id: changes |
| 40 | + run: | |
| 41 | + set -euo pipefail |
| 42 | + base=$(git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD) |
| 43 | + external=$(git diff --name-only "$base" HEAD -- 'docs' 'README.md' 'CHANGELOG.md' 'crates' | paste -sd, -) |
| 44 | + { |
| 45 | + echo "external=$external" |
| 46 | + echo "has_external=$([ -n "$external" ] && echo true || echo false)" |
| 47 | + } >> "$GITHUB_OUTPUT" |
| 48 | +
|
| 49 | + - name: Dispatch to docs composer (makegov/docs) |
| 50 | + if: steps.changes.outputs.has_external == 'true' |
| 51 | + env: |
| 52 | + GH_TOKEN: ${{ secrets.DOCS_DISPATCH_TOKEN }} |
| 53 | + TARGET: ${{ vars.DOCS_TARGET_REPO || 'makegov/docs' }} |
| 54 | + run: | |
| 55 | + gh api "repos/$TARGET/dispatches" \ |
| 56 | + -f event_type=external_updated \ |
| 57 | + -f "client_payload[source_repo]=${{ github.repository }}" \ |
| 58 | + -f "client_payload[source_ref]=${{ github.sha }}" \ |
| 59 | + -f "client_payload[changed_paths]=${{ steps.changes.outputs.external }}" |
0 commit comments