## Summary pnpm.io's docs preview imported every documentation line, so this repo's docs workflows fetched `pnpm11/docs` from `release/11` before every preview. pnpm/pnpm.io#998 lets the importer take a list of lines, and lines left out keep the copies committed in pnpm/pnpm.io. - `docs.yml` runs `--preview 12.x pnpr`, no longer fetches `release/11`, and pins the pnpm.io revision that accepts a line list. - The manual "publish all docs from main" sync in `sync-docs.yml` imports 12.x and pnpr only. Before, it also published `release/11`'s current 11.x docs, including unreleased changes. The 11.x docs on the website now change only when a v11 release syncs them. - `DOCUMENTATION.md` drops the `release/11` fetch from the local preview steps. `release/11` gets the matching change in a separate PR against that branch. ## Checklist - [x] Updated the documentation if needed. --- Written by an agent (Claude Code, claude-opus-5-5). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- codesmith:footer --> --- <a href="https://dashboardbackend.blacksmith.sh/track/run-proof?expires=1797974148&installation_model_id=426870&pr_number=18367&ref=codesmith_pr_footer&repository=pnpm%2Fpnpm&return_to=https%3A%2F%2Fgithub.com%2Fpnpm%2Fpnpm%2Fpull%2F18367&variant=see_it_in_action&signature=1be1d2edd667bcd8adba0c472dd2c125acbfd552c9031789986604b521c10f90"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-see-it-in-action-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/proof-see-it-in-action-v2-light.svg"><img alt="See it in action" src="https://pr-comments-assets.blacksmith.sh/codesmith/proof-see-it-in-action-v2-dark-3x.png" width="132" height="28"></picture></a> <sup><a href="https://app.blacksmith.sh/pnpm/codesmith/pnpm/pr/18367?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Documentation** * Documentation previews now include the 12.x and pnpr lines. * Preview syncs replace the website’s generated copies for the listed documentation lines; other lines continue to use the copies committed to the website. * Updated preview-sync guidance to use the website’s current main branch instead of fetching and restoring release/11 documentation. * Main-branch documentation syncs use the same preview targets; non-main sync behavior remains unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
176 lines
7.1 KiB
YAML
176 lines
7.1 KiB
YAML
name: Sync documentation
|
|
|
|
on:
|
|
# A maintainer publishes the draft GitHub release after approving the staged
|
|
# npm packages. A release event runs the workflow file from the tag, so it
|
|
# only dispatches the sync from the default branch. The token is limited to
|
|
# the push step.
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_tag:
|
|
description: Optional published release tag; leave empty to publish all docs from main
|
|
required: false
|
|
type: string
|
|
docs_commit:
|
|
description: Optional full SHA of a docs-only correction based on that tag
|
|
type: string
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
dispatch:
|
|
if: >-
|
|
github.event_name == 'release' &&
|
|
(startsWith(github.event.release.tag_name, 'v11.') ||
|
|
startsWith(github.event.release.tag_name, 'v12.') ||
|
|
startsWith(github.event.release.tag_name, 'pnpr@'))
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
actions: write
|
|
steps:
|
|
- name: Dispatch the sync from the default branch
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
run: gh workflow run sync-docs.yml -R "$GITHUB_REPOSITORY" --ref "$DEFAULT_BRANCH" -f release_tag="$RELEASE_TAG"
|
|
|
|
sync:
|
|
if: github.event_name == 'workflow_dispatch'
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
publish: ${{ steps.source.outputs.publish }}
|
|
main_sync: ${{ steps.source.outputs.main_sync }}
|
|
docs_commit: ${{ steps.source.outputs.docs_commit }}
|
|
line: ${{ steps.source.outputs.line }}
|
|
version: ${{ steps.source.outputs.version }}
|
|
website_commit: ${{ steps.website.outputs.commit }}
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
- name: Select the main or released documentation snapshot
|
|
id: source
|
|
env:
|
|
RELEASE_TAG: ${{ inputs.release_tag }}
|
|
DOCS_COMMIT: ${{ inputs.docs_commit }}
|
|
run: |
|
|
export GNUPGHOME="$(mktemp -d)"
|
|
chmod 700 "$GNUPGHOME"
|
|
trap 'rm -rf "$GNUPGHOME"' EXIT
|
|
gpg --batch --quiet --import .github/release-keys/*.asc
|
|
node .github/scripts/prepare-docs-sync.mjs
|
|
- name: Check out the documentation snapshot
|
|
if: steps.source.outputs.publish == 'true'
|
|
env:
|
|
DOCS_COMMIT: ${{ steps.source.outputs.docs_commit }}
|
|
run: git worktree add --detach "$RUNNER_TEMP/docs-source" "$DOCS_COMMIT"
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
if: steps.source.outputs.publish == 'true'
|
|
with:
|
|
repository: pnpm/pnpm.io
|
|
ref: main
|
|
path: website
|
|
persist-credentials: false
|
|
- name: Record the website revision before executing website code
|
|
if: steps.source.outputs.publish == 'true'
|
|
id: website
|
|
working-directory: website
|
|
run: echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
|
- uses: pnpm/setup@731dfb6463bbd11c11fd0ee11fe00ed0e36d48a1 # v3.2.0
|
|
if: steps.source.outputs.publish == 'true'
|
|
with:
|
|
runtime: node@22
|
|
install: false
|
|
- name: Install the website dependencies
|
|
if: steps.source.outputs.publish == 'true'
|
|
working-directory: website
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Sync and verify the pages
|
|
if: steps.source.outputs.publish == 'true'
|
|
working-directory: website
|
|
env:
|
|
MAIN_SYNC: ${{ steps.source.outputs.main_sync }}
|
|
LINE: ${{ steps.source.outputs.line }}
|
|
VERSION: ${{ steps.source.outputs.version }}
|
|
RELEASE_COMMIT: ${{ steps.source.outputs.release_commit }}
|
|
DOCS_COMMIT: ${{ steps.source.outputs.docs_commit }}
|
|
run: |
|
|
if [ "$MAIN_SYNC" = true ]; then
|
|
node scripts/sync-docs.mjs "$RUNNER_TEMP/docs-source" --preview 12.x pnpr
|
|
else
|
|
node scripts/sync-docs.mjs "$RUNNER_TEMP/docs-source" "$LINE" "$VERSION" "$RELEASE_COMMIT" "$DOCS_COMMIT"
|
|
fi
|
|
pnpm build
|
|
pnpm check-urls
|
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
if: steps.source.outputs.publish == 'true'
|
|
with:
|
|
name: generated-documentation
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
path: |
|
|
website/docs
|
|
website/pnpr-docs
|
|
website/versioned_docs/version-11.x
|
|
website/sidebars.json
|
|
website/sidebars-pnpr.json
|
|
website/versioned_sidebars/version-11.x-sidebars.json
|
|
website/static/docs-assets
|
|
website/blog/releases
|
|
website/docs-sync.json
|
|
|
|
publish:
|
|
needs: sync
|
|
if: needs.sync.outputs.publish == 'true'
|
|
runs-on: ubuntu-latest
|
|
environment: docs-sync
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
repository: pnpm/pnpm.io
|
|
ref: ${{ needs.sync.outputs.website_commit }}
|
|
path: website
|
|
persist-credentials: false
|
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
with:
|
|
name: generated-documentation
|
|
path: generated-documentation
|
|
- name: Copy only documentation into the clean checkout
|
|
run: node .github/scripts/copy-docs-artifact.mjs generated-documentation website
|
|
- name: Commit the generated documentation
|
|
id: commit
|
|
working-directory: website
|
|
env:
|
|
MAIN_SYNC: ${{ needs.sync.outputs.main_sync }}
|
|
DOCS_COMMIT: ${{ needs.sync.outputs.docs_commit }}
|
|
VERSION: ${{ needs.sync.outputs.version }}
|
|
LINE: ${{ needs.sync.outputs.line }}
|
|
run: |
|
|
git add docs pnpr-docs sidebars-pnpr.json versioned_docs/version-11.x versioned_sidebars/version-11.x-sidebars.json sidebars.json static/docs-assets blog/releases docs-sync.json
|
|
if git diff --cached --quiet; then exit 0; fi
|
|
git config user.name 'pnpm docs sync'
|
|
git config user.email 'pnpm-docs-sync@users.noreply.github.com'
|
|
if [ "$MAIN_SYNC" = true ]; then
|
|
title="docs: sync product documentation from main"
|
|
else
|
|
title="docs: sync ${LINE} documentation for ${VERSION}"
|
|
fi
|
|
git commit -m "$title" -m "Generated from pnpm/pnpm commit ${DOCS_COMMIT}. Written by release automation."
|
|
echo 'changed=true' >> "$GITHUB_OUTPUT"
|
|
- name: Push the verified documentation commit
|
|
if: steps.commit.outputs.changed == 'true'
|
|
working-directory: website
|
|
env:
|
|
GH_TOKEN: ${{ secrets.DOCS_SYNC_TOKEN }}
|
|
run: |
|
|
test -n "$GH_TOKEN" || { echo '::error::Configure DOCS_SYNC_TOKEN in the docs-sync environment'; exit 1; }
|
|
gh auth setup-git
|
|
git push origin HEAD:main
|