Skip to content

Commit 73aa71c

Browse files
committed
deploy branch specific docs
1 parent c76760a commit 73aa71c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

.github/workflows/docs.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,25 @@ jobs:
4242

4343
- name: Deploy to GitHub Pages
4444
uses: peaceiris/actions-gh-pages@v3
45-
with:
46-
github_token: ${{ secrets.GITHUB_TOKEN }}
47-
publish_dir: ./docs/book
48-
publish_branch: gh-pages
49-
force_orphan: true
45+
run: |
46+
git config user.name "github-actions[bot]"
47+
git config user.email "github-actions[bot]@users.noreply.github.com"
48+
49+
BRANCH_NAME=${GITHUB_REF#refs/heads/}
50+
SAFE_BRANCH_NAME=$(echo "$BRANCH_NAME" | tr '/' '-')
51+
52+
git clone --depth=1 --branch gh-pages https://github.com/${{ github.repository }} gh-pages || \
53+
git clone --depth=1 https://github.com/${{ github.repository }} gh-pages && \
54+
cd gh-pages && \
55+
git checkout --orphan gh-pages
56+
57+
cd gh-pages
58+
59+
rm -rf "$SAFE_BRANCH_NAME"
60+
mkdir -p "$SAFE_BRANCH_NAME"
61+
62+
cp -r ../docs/book/* "$SAFE_BRANCH_NAME/"
63+
64+
git add "$SAFE_BRANCH_NAME"
65+
git commit -m "Update docs for branch $BRANCH_NAME" || echo "No changes to commit"
66+
git push origin gh-pages

0 commit comments

Comments
 (0)