diff --git a/.github/workflows/regen-docs.yml b/.github/workflows/regen-docs.yml index 7a3461c..f32e646 100644 --- a/.github/workflows/regen-docs.yml +++ b/.github/workflows/regen-docs.yml @@ -1,39 +1,75 @@ name: Regen Docs + +# Tells the docs sites to recompile this module's API docs. +# +# Fires on a change to apidoc/ and on a published release, rather than on every +# merged pull request, so a direct push to master is not missed. on: workflow_dispatch: pull_request: - types: [ closed ] - branches: [ master ] - paths: [ 'apidoc/**' ] + paths: ['apidoc/**'] + push: + branches: [master] + paths: ['apidoc/**'] + release: + types: [published] jobs: regen: - if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest - name: Trigger Regen - + name: Lint steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Setup node + uses: actions/setup-node@v7 + with: + node-version: '26' + cache: npm - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: '16' - registry-url: 'https://registry.npmjs.org' + - name: Install dependencies + run: npm ci - - name: Install dependencies - run: npm ci - if: steps.node-cache.outputs.cache-hit != 'true' + - name: Lint + run: npm run lint:docs - - run: npm run lint:docs - name: Lint - - - name: Repository Dispatch - uses: peter-evans/repository-dispatch@v2 - with: - event-type: regen-api-docs - token: ${{ secrets.REGEN_DOCS_GITHUB_TOKEN }} - repository: tidev/titanium-docs + # titaniumsdk.com. The dispatch lives in titanium-www so the payload shape is + # defined once for all 17 source repos instead of copied into each. + # + # Deliberately independent of the lint job. Gating the dispatch on it means an + # unrelated tooling problem stops the docs updating and nothing says so -- + # ti.coremotion cannot run `npm ci` at all today because its lockfile is out of + # sync with its package.json. Genuinely malformed apidoc still cannot ship: the + # compile in titanium-www fails on it and commits nothing. + notify: + # Skipped on pull_request: a proposed change gets linted, not published. + # Skipped in forks: they hold no dispatch token, so this would only ever + # produce a failing run. The allowlist in titanium-www is the actual + # boundary -- a fork's payload names the fork, which is not on it. + if: github.event_name != 'pull_request' && github.repository_owner == 'tidev' + uses: tidev/titanium-www/.github/workflows/notify-api-docs.yml@main + secrets: + dispatch-token: ${{ secrets.REGEN_DOCS_GITHUB_TOKEN }} + + # The old pipeline, kept running alongside the new one so the site currently + # being served stays current while the replacement is proven. It carries no + # payload because titanium-docs does not read one -- it rebuilds every source + # repo on any dispatch, which is the inefficiency titanium-www replaces. + # + # Delete this job once titaniumsdk.com is served from titanium-www (TI-52). + notify-legacy: + # Skipped on pull_request: a proposed change gets linted, not published. + # Skipped in forks: they hold no dispatch token, so this would only ever + # produce a failing run. The allowlist in titanium-www is the actual + # boundary -- a fork's payload names the fork, which is not on it. + if: github.event_name != 'pull_request' && github.repository_owner == 'tidev' + runs-on: ubuntu-latest + name: Notify titanium-docs (legacy) + steps: + - name: Repository dispatch + uses: peter-evans/repository-dispatch@v4 + with: + event-type: regen-api-docs + repository: tidev/titanium-docs + token: ${{ secrets.REGEN_DOCS_GITHUB_TOKEN }}