-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (40 loc) · 1.8 KB
/
buildbooks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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