티스토리 뷰

mdBook 설치

rust 설치 필요!

 

Install Rust

A language empowering everyone to build reliable and efficient software.

www.rust-lang.org

$ 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. 배포된 페이지 확인

 

 

Chapter 1 - go-ethereum 박살내기

 

piatoss3612.github.io

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

참고 자료

 

GitHub - rust-lang/mdBook: Create book from markdown files. Like Gitbook but implemented in Rust

Create book from markdown files. Like Gitbook but implemented in Rust - GitHub - rust-lang/mdBook: Create book from markdown files. Like Gitbook but implemented in Rust

github.com

 

Automated Deployment: GitHub Actions

Create book from markdown files. Like Gitbook but implemented in Rust - rust-lang/mdBook

github.com

 

최근에 올라온 글
최근에 달린 댓글
«   2025/01   »
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
Total
Today
Yesterday
글 보관함