Skip to content

Commit bad5bcb

Browse files
committed
Refactor GitHub Actions documentation update workflow to use Git worktree for pages branch deployment
- Replace hardcoded destination repository with in-repository pages branch deployment - Use git worktree to manage pages branch checkout and updates - Simplify documentation deployment process by removing external repository clone - Improve workflow clarity and reduce complexity of documentation publishing
1 parent de60f0a commit bad5bcb

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

.github/workflows/update_docs.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77

88
env:
99
PYTHON_VERSION: '3.8'
10-
DEST_REPO: 'openmlsys/html-en'
1110
GIT_USER_NAME: 'GitHub Actions Bot'
1211
GIT_USER_EMAIL: 'github-actions[bot]@users.noreply.github.com'
1312

@@ -57,18 +56,20 @@ jobs:
5756
source venv/bin/activate
5857
sh build_html.sh
5958
60-
- name: Deploy to html-en repository
61-
env:
62-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
59+
- name: Deploy to pages branch
6360
run: |
64-
# Clone the destination repository
65-
git clone https://${GH_TOKEN}@github.com/${DEST_REPO}.git
61+
# Create and switch to a new worktree for the pages branch
62+
git worktree add --detach pages
63+
cd pages
64+
git checkout pages || git checkout --orphan pages
65+
66+
# Remove existing files to prepare for new content
67+
git rm -rf . || true
6668
6769
# Copy built documentation
68-
cp -r _build/html/* html-en/
70+
cp -r ../_build/html/* .
6971
7072
# Configure git
71-
cd html-en
7273
git config user.name "${GIT_USER_NAME}"
7374
git config user.email "${GIT_USER_EMAIL}"
7475
@@ -82,15 +83,18 @@ jobs:
8283
Run ID: ${{ github.run_id }}
8384
Triggered by: ${{ github.event_name }}"
8485
85-
# Push changes
86-
git push origin main
86+
# Push changes to pages branch
87+
git push origin pages
8788
else
8889
echo "No changes to commit"
8990
fi
91+
92+
# Clean up the worktree
93+
cd ..
94+
git worktree remove pages
9095
9196
- name: Clean up
9297
if: always()
9398
run: |
9499
rm -rf venv
95-
rm -rf html-en
96100
rm -rf d2l-book

0 commit comments

Comments
 (0)