티스토리 뷰
mdBook 설치
rust 설치 필요!
$ cargo install mdbook
mdBook 생성 및 로컬에서 실행
$ mdbook init mdbook
$ cd mdbook
$ mdbook serve --open
Github Page 배포
1. Github Actions를 통한 Github Page 생성 활성화
2. Github Actions를 사용해 mdBook 배포
name: book
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write # To push a branch
pages: write # To push to a GitHub Pages site
id-token: write # To update the deployment status
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook-build # Create a directory to extract the binary to
curl -sSL $url | tar -xz --directory=./mdbook-build
echo `pwd`/mdbook-build >> $GITHUB_PATH
- name: Build Book
run: |
# This assumes your book is in the root of your repository.
# Just add a `cd` here if you need to change to another directory.
cd mdbook # Change to the directory where your book.toml is
mdbook build # Build the book
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: 'mdbook/book' # Change this to the directory where your book is built
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
3. 배포된 페이지 확인
4. (Optional) 테스트 추가
name: book
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
on:
push:
branches:
- main
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: write # To push a branch
pull-requests: write # To create a PR from that branch
steps:
- uses: actions/checkout@master
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install stable
rustup default stable
- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir bin
curl -sSL $url | tar -xz --directory=bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Run tests
run: |
cd mdbook
mdbook test
deploy:
runs-on: ubuntu-latest
permissions:
contents: write # To push a branch
pages: write # To push to a GitHub Pages site
id-token: write # To update the deployment status
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook-build # Create a directory to extract the binary to
curl -sSL $url | tar -xz --directory=./mdbook-build
echo `pwd`/mdbook-build >> $GITHUB_PATH
- name: Build Book
run: |
# This assumes your book is in the root of your repository.
# Just add a `cd` here if you need to change to another directory.
cd mdbook # Change to the directory where your book.toml is
mdbook build # Build the book
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: 'mdbook/book' # Change this to the directory where your book is built
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
참고 자료
'개발 부스러기' 카테고리의 다른 글
Solidity 런타임 바이트코드 분해하기 (0) | 2024.02.13 |
---|---|
Hyperlane V3를 사용한 Crosschain NFT (0) | 2024.02.12 |
WSL에서 Terraform 사용하기 (0) | 2023.12.27 |
WSL에서 Github 사용하기 (0) | 2023.12.26 |
WSL에서 Go 사용하기 (0) | 2023.12.26 |