|
| 1 | +name: Docs content cache |
| 2 | +description: Reuse validated incremental documentation compilation without sharing concurrent writer snapshots. |
| 3 | +inputs: |
| 4 | + provider: |
| 5 | + description: The CI_PROVIDER repo variable. |
| 6 | + required: false |
| 7 | + default: '' |
| 8 | + namespace: |
| 9 | + description: A distinct name for each concurrently writing job. |
| 10 | + required: true |
| 11 | + generate: |
| 12 | + description: Generate and validate content after restoring it. Set false only when the following build already runs content:generate. |
| 13 | + required: false |
| 14 | + default: 'true' |
| 15 | + next-cache: |
| 16 | + description: Also restore the incremental Next build cache. |
| 17 | + required: false |
| 18 | + default: 'false' |
| 19 | +runs: |
| 20 | + using: composite |
| 21 | + steps: |
| 22 | + - name: Identify the compiler runtime |
| 23 | + id: runtime |
| 24 | + shell: bash |
| 25 | + env: |
| 26 | + CACHE_NAMESPACE: ${{ inputs.namespace }} |
| 27 | + GENERATE: ${{ inputs.generate }} |
| 28 | + NEXT_CACHE: ${{ inputs.next-cache }} |
| 29 | + run: | |
| 30 | + [[ "$CACHE_NAMESPACE" =~ ^[a-z0-9][a-z0-9-]*$ ]] |
| 31 | + [[ "$GENERATE" == true || "$GENERATE" == false ]] |
| 32 | + [[ "$NEXT_CACHE" == true || "$NEXT_CACHE" == false ]] |
| 33 | + toolchain=$(node --version) |
| 34 | + toolchain="$toolchain-$(bun --version)" |
| 35 | + echo "toolchain=$toolchain" >> "$GITHUB_OUTPUT" |
| 36 | + compiler=$(git ls-files -s -- bun.lock package.json patches apps/docs/package.json apps/docs/scripts/compile-content.ts apps/docs/lib apps/docs/components/workflow-preview packages | sha256sum | awk '{ print $1 }') |
| 37 | + echo "compiler=$compiler" >> "$GITHUB_OUTPUT" |
| 38 | + - name: Restore incremental content |
| 39 | + continue-on-error: true |
| 40 | + uses: ./.github/actions/cache |
| 41 | + with: |
| 42 | + provider: ${{ inputs.provider }} |
| 43 | + key: ${{ github.repository }}-docs-content-v1-${{ inputs.namespace }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.runtime.outputs.toolchain }}-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && format('-fork-{0}', github.event.pull_request.number) || '' }}-${{ steps.runtime.outputs.compiler }} |
| 44 | + path: ./apps/docs/.content |
| 45 | + - name: Bound restored content |
| 46 | + shell: bash |
| 47 | + run: bash .github/actions/docs-content-cache/prune.sh content |
| 48 | + - name: Restore incremental Next build |
| 49 | + if: inputs.next-cache == 'true' |
| 50 | + continue-on-error: true |
| 51 | + uses: ./.github/actions/cache |
| 52 | + with: |
| 53 | + provider: ${{ inputs.provider }} |
| 54 | + key: ${{ github.repository }}-docs-next-v1-${{ inputs.namespace }}-${{ runner.os }}-${{ runner.arch }}-${{ steps.runtime.outputs.toolchain }}-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && format('-fork-{0}', github.event.pull_request.number) || '' }}-${{ hashFiles('bun.lock') }} |
| 55 | + path: ./apps/docs/.next/cache |
| 56 | + - name: Bound the incremental build cache |
| 57 | + if: inputs.next-cache == 'true' |
| 58 | + shell: bash |
| 59 | + run: bash .github/actions/docs-content-cache/prune.sh next |
| 60 | + - name: Generate and validate documentation modules |
| 61 | + id: generate |
| 62 | + if: inputs.generate == 'true' |
| 63 | + shell: bash |
| 64 | + run: bun run --cwd apps/docs content:generate --prune |
| 65 | + - name: Bound content after an unsuccessful generation |
| 66 | + if: always() && inputs.generate == 'true' && steps.generate.outcome != 'success' |
| 67 | + shell: bash |
| 68 | + run: bash .github/actions/docs-content-cache/prune.sh content |
0 commit comments