Skip to content

Commit 897f802

Browse files
committed
Preserve PR previews when deploying release docs to gh-pages
1 parent aad2bb8 commit 897f802

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/release-management.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,26 @@ jobs:
164164
- name: Install MkDocs
165165
run: pip install 'mkdocs-material>=9.0.0,<10.0.0'
166166

167-
- name: Build and deploy MkDocs
168-
run: mkdocs gh-deploy
167+
- name: Build docs
168+
run: mkdocs build
169+
170+
# The `gh-pages` branch also holds PR previews under `pr-preview/` (see
171+
# pull-request-preview.yml), so `mkdocs gh-deploy` can't be used here: it
172+
# replaces the entire branch content, which would wipe those previews.
173+
# Deploy manually instead, replacing everything on `gh-pages` except
174+
# `pr-preview/` and pushing normally.
175+
- name: Deploy docs
176+
run: |
177+
git fetch origin gh-pages:refs/remotes/origin/gh-pages
178+
git worktree add -B gh-pages gh-pages-worktree refs/remotes/origin/gh-pages
179+
find gh-pages-worktree -mindepth 1 -maxdepth 1 ! -name pr-preview ! -name .git -exec rm -rf {} +
180+
cp -a site/. gh-pages-worktree/
181+
touch gh-pages-worktree/.nojekyll
182+
cd gh-pages-worktree
183+
git add -A
184+
if git diff --cached --quiet; then
185+
echo "No changes to deploy."
186+
else
187+
git commit -m "Deploy docs for React UI v${{ needs.test_and_build.outputs.version }} (${GITHUB_SHA:0:7})"
188+
git push origin gh-pages
189+
fi

0 commit comments

Comments
 (0)