Skip to content

Commit 6c502e7

Browse files
sdaultonfacebook-github-bot
authored andcommitted
Fix Docusaurus versioning error in publish_website workflow
Summary: Fix Docusaurus versioning error when release workflow is re-run ## Problem The 'Create new docusaurus version' step in publish_website.yml fails with: ``` Error: [docs]: this version already exists! Use a version tag that does not already exist. ``` This occurs when the release workflow is re-run for the same version (e.g., after a partial failure or manual re-trigger), because the version was already created and pushed to gh-pages in a previous run. ## Solution Make the versioning step idempotent by checking if the version already exists in versions.json before attempting to create it: 1. Extract the version tag and remove the optional 'v' prefix 2. Check if versions.json exists and contains the version 3. Skip versioning if the version already exists, otherwise proceed normally This allows the workflow to be safely re-run without failing. Differential Revision: D95305476
1 parent ee72a65 commit 6c502e7

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

.github/workflows/publish_website.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,19 @@ jobs:
8686
python3 scripts/convert_ipynb_to_mdx.py --clean
8787
cd website
8888
yarn
89-
yarn docusaurus docs:version ${{ inputs.new_version }}
9089
91-
git add versioned_docs/ versioned_sidebars/ versions.json
92-
git commit -m "Create version ${{ inputs.new_version }} of site in Docusaurus"
93-
git push --force origin HEAD:gh-pages
90+
# Check if this version already exists in versions.json
91+
VERSION_TAG="${{ inputs.new_version }}"
92+
VERSION_TAG="${VERSION_TAG#v}" # Remove optional "v" prefix for comparison
93+
if [ -f versions.json ] && grep -q "\"$VERSION_TAG\"" versions.json; then
94+
echo "Version $VERSION_TAG already exists in versions.json, skipping versioning step"
95+
else
96+
yarn docusaurus docs:version ${{ inputs.new_version }}
97+
98+
git add versioned_docs/ versioned_sidebars/ versions.json
99+
git commit -m "Create version ${{ inputs.new_version }} of site in Docusaurus"
100+
git push --force origin HEAD:gh-pages
101+
fi
94102
- name: Build website
95103
run: |
96104
bash scripts/build_docs.sh -b

0 commit comments

Comments
 (0)