Skip to content

Commit 96b9546

Browse files
committed
chore: simplify documentation publishing in GitHub Actions workflow
- Replaced the manual push process with the peaceiris/actions-gh-pages action for publishing documentation to the gh-pages branch. - Streamlined the workflow by removing checks for TARGET_REPO and TARGET_TOKEN secrets, as they are no longer necessary with the new action.
1 parent 7bc0190 commit 96b9546

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

.github/workflows/publish-docs.yml

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,10 @@ jobs:
4646
run: |
4747
bash -ex script/build_docs.sh
4848
49-
- name: Push built docs to another repo
50-
run: |
51-
# Hide sensitive info in logs
52-
echo "::add-mask::${{ secrets.TARGET_TOKEN }}"
53-
echo "::add-mask::${{ secrets.TARGET_REPO }}"
54-
if [[ -z "${{ secrets.TARGET_REPO }}" ]]; then
55-
echo "TARGET_REPO secret is empty"
56-
exit 1
57-
fi
58-
if [[ -z "${{ secrets.TARGET_TOKEN }}" ]]; then
59-
echo "TARGET_TOKEN secret is empty"
60-
exit 1
61-
fi
62-
TARGET_REPO_URL="https://github.com/${{ secrets.TARGET_REPO }}.git"
63-
echo "Publishing docs to configured target repository"
64-
65-
git clone "${TARGET_REPO_URL}" -b main target_repo
66-
cd target_repo
67-
git config --local user.name "github-actions[bot]"
68-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
69-
find . -mindepth 1 -maxdepth 1 ! -name ".github" ! -name "." ! -name ".git" -exec rm -rf {} +
70-
shopt -s dotglob
71-
cp -r ../docs/_build/html/* ./
72-
git add .
73-
if [[ -n "$(git status --porcelain)" ]]; then
74-
# If there are changes, commit and push
75-
git commit -m "Update docs"
76-
git push "https://github-actions[bot]:${{ secrets.TARGET_TOKEN }}@${TARGET_REPO_URL##*://}" main
77-
else
78-
echo "No changes detected, skipping commit and push."
79-
fi
49+
- name: Publish docs to gh-pages
50+
uses: peaceiris/actions-gh-pages@v4
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
publish_dir: ./docs/_build/html
54+
publish_branch: gh-pages
55+
force_orphan: true

0 commit comments

Comments
 (0)