Merge branch 'master' of https://github.com/Zhewana/BlogBook #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-my-book | |
on: [push] | |
jobs: | |
build: | |
env: | |
TOKEN: ${{ secrets.TOKEN }} | |
REF: github.com/${{github.repository}} | |
MYEMAIL: 1312560006@qq.com | |
MYNAME: ${{github.repository_owner}} | |
REPO_NAME: ${{ github.event.repository.name }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 10.x | |
- name: Pregenerate SUMMARY.md | |
run: | | |
find . -maxdepth 1 -type d \( ! -name . \) -not -path "./.*" -not -path "./node*" -not -path "./_*" -exec bash -c "cd '{}'; pwd; rm -rf ./_book; cp -f ../GenerateSummary.py ./ && python3 GenerateSummary.py; rm GenerateSummary.py" \; | |
- name: Install GitBook | |
run: | | |
npm install -g gitbook-cli | |
gitbook --version | |
- name: Build all books | |
run: | | |
find . -maxdepth 1 -type d \( ! -name . \) -not -path "./.*" -not -path "./node*" -not -path "./_*" -exec bash -c "cd '{}'; pwd && gitbook init; cp -f ../book.json ./; gitbook install; rm -r _book; gitbook build; rm -r node_modules; rm book.json" \; | |
- name: Push all files to master branch | |
run: | | |
git config --global user.email "${MYEMAIL}" | |
git config --global user.name "${MYNAME}" | |
git remote add ${REPO_NAME} "https://${TOKEN}@${REF}" | |
git add . | |
git commit -m "ZheWana-bot: Update book." || exit 0 | |
git push --force ${REPO_NAME} | |
- name: Sync repo to Gitee | |
run: | | |
git remote add Gitee${REPO_NAME} https://${{ secrets.GITEE_USER_NAME }}:${{ secrets.GITEE_TOKEN }}@gitee.com/${{ secrets.GITEE_USER_NAME }}/${REPO_NAME}.git | |
git fetch --unshallow ${REPO_NAME} | |
git push --force Gitee${REPO_NAME} master:master | |