Skip to content

Commit 058f230

Browse files
sdaultonmeta-codesync[bot]
authored andcommitted
Fix Docusaurus versioning error in publish_website workflow (#3221)
Summary: Pull Request resolved: #3221 Fix website deployment workflow issues ## Issue 1: Docusaurus version deletion not matching 'v' prefixed directories ### Problem The 'Delete existing similar versions from Docusaurus' step fails to find and delete existing versions when the release workflow is re-run. This causes the subsequent 'Create new docusaurus version' step to fail with: ``` Error: [docs]: this version already exists! Use a version tag that does not already exist. ``` ### Root Cause When Docusaurus creates a version with `yarn docusaurus docs:version v0.17.2`, it creates directories/files with the 'v' prefix: - `versioned_docs/version-v0.17.2/` - `versioned_sidebars/version-v0.17.2-sidebars.json` But the delete step was stripping the 'v' prefix before searching, so the glob `version-0.17.*` never matched `version-v0.17.2/`. ### Solution Search for both patterns (with and without 'v' prefix). --- ## Issue 2: Node.js heap out of memory during Docusaurus build ### Problem The `docusaurus build` command fails with: ``` FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ``` ### Root Cause The build consumes ~4GB memory which exceeds Node.js default heap limit. ### Solution Set `NODE_OPTIONS="--max-old-space-size=8192"` before running `yarn build` in `scripts/build_docs.sh` to increase the heap limit to 8GB. Reviewed By: saitcakmak Differential Revision: D95305476 fbshipit-source-id: 454d6a5ce69cdbef457c8b42d2798519abfbd686
1 parent ee72a65 commit 058f230

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

.github/workflows/publish_website.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,18 @@ jobs:
6464
run: |
6565
# Delete existing versions for same Major and Minor version numbers.
6666
# We do this to keep only the latest patch for a given major/minor version.
67-
MAJOR_MINOR_VERSION=$(cut -d '.' -f 1-2 <<< ${{ inputs.new_version }}) # remove patch number
68-
MAJOR_MINOR_VERSION=${MAJOR_MINOR_VERSION#v} # remove optional "v" prefix
67+
MAJOR_MINOR_VERSION=$(cut -d '.' -f 1-2 <<< ${{ inputs.new_version }}) # remove patch number (e.g., "v0.17")
6968
for dir in website/versioned_docs/version-$MAJOR_MINOR_VERSION.*; do
7069
if [ -d "$dir" ]; then
7170
OLD_VERSION=$(basename "$dir" | sed 's/^version-//') # remove "version-" prefix from the directory name
72-
echo "Deleting older version $OLD_VERSION with the same major and minor version numbers as $NEW_VERSION"
71+
echo "Deleting older version $OLD_VERSION with the same major and minor version numbers as ${{ inputs.new_version }}"
7372
# Delete version from the three locations Docusaurus uses:
7473
# - versioned_docs/version-X.Y.Z/
7574
# - versioned_sidebars/version-X.Y.Z-sidebars.json
7675
# - versions.json
7776
# https://docusaurus.io/docs/versioning#deleting-an-existing-version
7877
rm -rf "$dir"
79-
rm "website/versioned_sidebars/version-$OLD_VERSION-sidebars.json"
78+
rm -f "website/versioned_sidebars/version-$OLD_VERSION-sidebars.json"
8079
sed -i "/\"$OLD_VERSION\"/d" website/versions.json
8180
fi
8281
done
@@ -92,6 +91,9 @@ jobs:
9291
git commit -m "Create version ${{ inputs.new_version }} of site in Docusaurus"
9392
git push --force origin HEAD:gh-pages
9493
- name: Build website
94+
env:
95+
# Increase Node.js heap memory to avoid OOM during large Docusaurus builds
96+
NODE_OPTIONS: "--max-old-space-size=8192"
9597
run: |
9698
bash scripts/build_docs.sh -b
9799
- name: Upload website build as artifact

0 commit comments

Comments
 (0)