Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 154 additions & 4 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,57 @@ jobs:
echo "No changes detected across docs repo or any addon since $LAST_RUN — skipping build."
echo "changed=false" >> "$GITHUB_OUTPUT"

# ── Build & deploy ───────────────────────────────────────────────────────────
build-and-deploy:
# ── Locale chunk planning ────────────────────────────────────────────────────
plan-locale-chunks:
needs: check-changes
runs-on: ubuntu-latest
outputs:
chunks: ${{ steps.plan.outputs.chunks }}
steps:
- uses: actions/checkout@v6
Comment on lines +112 to +119

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing if condition causes unnecessary job execution.

Unlike prepare-docs-source and build-locale-chunk, this job lacks the skip condition. It will run even on scheduled events when changed=false, wasting CI minutes. Add the same condition for consistency:

   plan-locale-chunks:
     needs: check-changes
+    if: needs.check-changes.outputs.changed == 'true' || github.event_name != 'schedule'
     runs-on: ubuntu-latest
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# ── Locale chunk planning ────────────────────────────────────────────────────
plan-locale-chunks:
needs: check-changes
runs-on: ubuntu-latest
outputs:
chunks: ${{ steps.plan.outputs.chunks }}
steps:
- uses: actions/checkout@v6
# ── Locale chunk planning ────────────────────────────────────────────────────
plan-locale-chunks:
needs: check-changes
if: needs.check-changes.outputs.changed == 'true' || github.event_name != 'schedule'
runs-on: ubuntu-latest
outputs:
chunks: ${{ steps.plan.outputs.chunks }}
steps:
- uses: actions/checkout@v6
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 119-119: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 119-119: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-docs.yml around lines 112 - 119, The
plan-locale-chunks job is missing an if condition that prevents it from running
unnecessarily on scheduled events. Add an if condition to the plan-locale-chunks
job that matches the skip condition already implemented in the
prepare-docs-source and build-locale-chunk jobs. This will ensure the job only
runs when appropriate and avoids wasting CI minutes on scheduled events when no
changes are detected.


- name: Plan locale chunks
id: plan
shell: bash
run: |
set -euo pipefail
python3 <<'PY'
import json
import os
import re
from pathlib import Path

chunk_size = 10
config = Path('docusaurus.config.js').read_text(encoding='utf-8')
match = re.search(r'locales:\s*\[(.*?)\]\s*,\s*localeConfigs', config, re.S)
if not match:
raise SystemExit('Unable to find i18n.locales in docusaurus.config.js')

locales = re.findall(r"'([^']+)'", match.group(1))
if not locales or locales[0] != 'en':
raise SystemExit('Expected en to be the first Docusaurus locale')

chunks = [{'chunk': '00-en', 'locales': 'en'}]
translated_locales = locales[1:]
for index in range(0, len(translated_locales), chunk_size):
chunk_number = (index // chunk_size) + 1
chunk_locales = translated_locales[index:index + chunk_size]
chunks.append({
'chunk': f'{chunk_number:02d}',
'locales': ' '.join(chunk_locales),
})

with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as output:
output.write(f'chunks={json.dumps(chunks)}\n')

with open(os.environ['GITHUB_STEP_SUMMARY'], 'a', encoding='utf-8') as summary:
summary.write('## Locale build chunks\n\n')
for chunk in chunks:
summary.write(f"- `{chunk['chunk']}`: `{chunk['locales']}`\n")
PY

# ── Generated source preparation ─────────────────────────────────────────────
prepare-docs-source:
needs: check-changes
# Always build on push/manual; skip scheduled runs when nothing changed.
if: needs.check-changes.outputs.changed == 'true' || github.event_name != 'schedule'
Expand Down Expand Up @@ -190,8 +239,109 @@ jobs:
run: bash scripts/generate-hooks.sh
continue-on-error: true

- name: Build documentation site
run: npx docusaurus build
- name: Upload prepared docs source
uses: actions/upload-artifact@v4
with:
name: prepared-docs-source
path: |
docs
i18n
scripts
src
static
docusaurus.config.js
sidebars.js
package.json
package-lock.json
if-no-files-found: error
retention-days: 1
compression-level: 3

# ── Parallel locale builds ───────────────────────────────────────────────────
build-locale-chunk:
name: Build locale chunk ${{ matrix.chunk }}
needs:
- check-changes
- plan-locale-chunks
- prepare-docs-source
# Always build on push/manual; skip scheduled runs when nothing changed.
if: needs.check-changes.outputs.changed == 'true' || github.event_name != 'schedule'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.plan-locale-chunks.outputs.chunks) }}
steps:
- name: Download prepared docs source
uses: actions/download-artifact@v4
with:
name: prepared-docs-source
path: .

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build locale chunk
env:
LOCALES: ${{ matrix.locales }}
shell: bash
run: |
set -euo pipefail
locale_args=()
for locale in $LOCALES; do
echo "Building locale: $locale"
locale_args+=(--locale "$locale")
done
rm -rf build .docusaurus
npx docusaurus build "${locale_args[@]}"

- name: Upload locale build artifact
uses: actions/upload-artifact@v4
with:
name: docs-build-${{ matrix.chunk }}
path: build/
if-no-files-found: error
retention-days: 1
compression-level: 3

# ── Build assembly & deploy ──────────────────────────────────────────────────
assemble-and-deploy:
needs:
- check-changes
- build-locale-chunk
# Always assemble on push/manual; skip scheduled runs when nothing changed.
if: needs.check-changes.outputs.changed == 'true' || github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- name: Download locale build artifacts
uses: actions/download-artifact@v4
with:
pattern: docs-build-*
path: locale-builds

- name: Assemble documentation site
shell: bash
run: |
set -euo pipefail
mkdir -p build
for artifact_dir in locale-builds/docs-build-*; do
if [ ! -d "$artifact_dir" ] || [ "$(basename "$artifact_dir")" = "docs-build-00-en" ]; then
continue
fi
rsync -a "$artifact_dir"/ build/
done
if [ ! -d locale-builds/docs-build-00-en ]; then
echo "Missing default English build artifact" >&2
exit 1
fi
rsync -a locale-builds/docs-build-00-en/ build/
test -f build/index.html

- name: Deploy to server
if: github.ref == 'refs/heads/main'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches: [main]
paths:
- '.github/workflows/deploy-docs.yml'
- '.github/workflows/validate-docs.yml'
- 'docusaurus.config.js'
- 'sidebars.js'
Expand All @@ -17,6 +18,7 @@ on:
push:
branches-ignore: [main]
paths:
- '.github/workflows/deploy-docs.yml'
- '.github/workflows/validate-docs.yml'
- 'docusaurus.config.js'
- 'sidebars.js'
Expand Down