Docusaurus 사용하기(2) - Git pages로 배포하기

이경은·2022년 10월 21일
1

Docusaurus 사용하기

목록 보기
2/2

🐲 Docusaurus Git Pages로 배포하기

🔥 유의 사항

  1. Repository 설정
    Git repository는 Public으로 설정해둬야 한다. (Private은 요금제 이용해야 함)
  2. Branch 설정
    git repository에서 Settings - Pages 에 들어가서 Build and deployment에서 Branch 를 main이나 다른 브런치가 아닌 gh-pages로 설정해야 한다.
    Docusaurus는 배포를 위한 브런치를 별도로 생성한다. 정확한 메커니즘은 모르겠지만, 배포 브런치로 설정을 해두어야 한다.

⚡ 배포하기

docusaurus.config.js 설정

const config = {
	...
  url: "https://{username or organization name}.github.io",
  baseUrl: "/${repository name}/",
  organizationName: "${username or organization}", 
  projectName: "${repository name}",
	...
}

.yaml 설정

  • 아래 스크립트는 docusaurus 공식 문서에서 제공하는 가이드를 복사했고, node version만 현재 프로젝트에 맞는 버전으로 설정했다.
name: Deploy to GitHub Pages

on:
  push:
    branches:
      - main

jobs:
  deploy:
    name: Deploy to GitHub Pages
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v3
        with:
          node-version: 16.14 # version setting
          cache: yarn

      - name: Install dependencies
        run: yarn install --frozen-lockfile
      - name: Build website
        run: yarn build

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./build
          user_name: github-actions[bot]
          user_email: 41898282+github-actions[bot]@users.noreply.github.com

참조

https://docusaurus.io/ko/docs/deployment#deploying-to-github-pages

profile
Web Developer

0개의 댓글