Skip to content

Commit 5adf28a

Browse files
Refactor deployment workflow to simplify gh-pages handling and preserve versioned directories
1 parent 78f647f commit 5adf28a

1 file changed

Lines changed: 3 additions & 23 deletions

File tree

.github/workflows/deploy_mkdocs.yml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,20 @@ jobs:
3939
git config --global user.name "GitHub Actions"
4040
git config --global user.email "github-actions@users.noreply.github.com"
4141
42-
- name: Checkout gh-pages branch
43-
run: |
44-
git fetch origin gh-pages:gh-pages || git checkout --orphan gh-pages
45-
git checkout gh-pages
46-
git reset --hard # Clean working directory
47-
48-
- name: Save existing content
49-
run: |
50-
mkdir -p temp
51-
# Save important files/directories that should be preserved
52-
# Copy all the vx.x.x folders to preserve them
53-
for dir in $(find . -maxdepth 1 -type d -name 'vx.*'); do
54-
if [ -d "$dir" ]; then
55-
cp -r "$dir" temp/
56-
fi
57-
done
58-
5942
- name: Build documentation
6043
run: |
6144
git checkout main
6245
mkdocs build
63-
ls -l site/
6446
6547
- name: Deploy documentation
6648
run: |
6749
git checkout gh-pages
68-
# Remove all content except .git and temp directory
69-
find . -mindepth 1 -maxdepth 1 ! -name '.git' ! -name 'temp' -exec rm -rf {} +
50+
# Remove all content except .git, site and vx.x.x directory
51+
find . -mindepth 1 -maxdepth 1 ! -name '.git' ! -name 'v*.*.*' ! -name 'site' -exec rm -rf {} +
7052
# Copy MkDocs output
7153
cp -r site/* .
72-
# Restore preserved content
73-
cp -r temp/* .
7454
# Clean up
75-
rm -rf site temp
55+
rm -rf site
7656
# Commit and push
7757
git add -A
7858
git commit -m "Deploy documentation updates" || echo "No changes to commit"

0 commit comments

Comments
 (0)