1.8 KiB
1.8 KiB
+++ date = "2023-10-05" tags = ["gitbook"] title = "gitbookのgh-actions" slug = "gitbook" +++
name: gitbook build and deploy
on:
push:
branches: src
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install ubuntu package
run: |
sudo apt-get update && sudo apt-get install calibre
#install japanese font if your document is JP
sudo apt-get install fonts-takao-mincho fonts-takao
- name: Run PDF export
run: |
# install n to downgrade npm version
sudo npm install -g n
fixed_npm=`n ls-remote --all 10 | head -n 1`
# downgrade to 10.x
sudo n ${fixed_npm}
# install gitbok-cli and call
npm install gitbook-cli
./node_modules/.bin/gitbook install
./node_modules/.bin/gitbook pdf
./node_modules/.bin/gitbook build
- name: Archive pdf artifacts
uses: actions/upload-artifact@v2
with:
name: output.pdf
path: book.pdf
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_branch: main
publish_dir: ./_book
user_name: 'ai[bot]'
user_email: '138105980+yui-syui-ai[bot]@users.noreply.github.com'
peaceiris/actions-gh-pages@v3は、private-repoに対応していないので、env:ACTIONS_DEPLOY_KEY
を作成して、そこに公開鍵を入れます。
そして、deploy-keyを作成して、秘密鍵を入れます。
$ ssh-keygen -f ~/.ssh/gh-pagaes
# 公開鍵
$ cat .ssh/gh-pages.pub
# 秘密鍵
$ cat .ssh/gh-pages