发布

手动部署

通过 hollow build 指令可以生成静态网站到 dist 目录下

docker run -v ${PWD}:/source bysir/hollow:master build -o /source/dist -t https://github.com/zbysir/hollow-theme/tree/master/hollow
./
├── dist/
└── contents/
    └── hello.md

随后将 dist 中的所有文件部署到 Github page 上就完成了。

使用 Github Action 发布

如果你的源文件托管在 Github 上,并且网站也想发布在 Github page 上,那么使用 Github Action 发布网站是最佳选择。

在 项目根目录下新建 .github/workflows/hollow.yaml,内容如下

name: Deploy Hollow with GitHub Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["master"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Pages
        uses: actions/configure-pages@v2
      - name: Build with Hollow
        uses: docker://bysir/hollow:master
        with:
          args: build
        env:
          SOURCE: .
          OUTPUT: ./dist
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: "./dist"

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1

现在只需要将源文件提交到 Github 上,等 30s 网站就自动上线了。

© 2023 Hollow's Blog - Tailwindcss + Hollow

GitHub