From f2de37a41cb18025dfe25bc2ade1d63615809aa0 Mon Sep 17 00:00:00 2001 From: Carrotzpc Date: Mon, 29 Jul 2024 12:01:37 +0800 Subject: [PATCH] ci: add deploy ghpages support --- .github/workflows/deploy-ghpages.yml | 44 ++++++++++++++++++++++++++++ example/.dumirc.ts | 3 ++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/deploy-ghpages.yml diff --git a/.github/workflows/deploy-ghpages.yml b/.github/workflows/deploy-ghpages.yml new file mode 100644 index 0000000..86f6965 --- /dev/null +++ b/.github/workflows/deploy-ghpages.yml @@ -0,0 +1,44 @@ +name: Deploy to GitHub Pages + +on: + # https://docs.github.com/zh/actions/using-workflows/events-that-trigger-workflows#workflow_run + workflow_run: + workflows: + - 'Build and Release' + types: + - completed +jobs: + deploy: + name: Deploy to GitHub Pages + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js v20.x + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install pnpm v9.x + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Install deps + run: pnpm install + + - name: Build website + run: npm run docs:build + + # Popular action to deploy to GitHub Pages: + # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GH_TOKEN }} + publish_dir: ./example/dist/dumi-theme-yunti diff --git a/example/.dumirc.ts b/example/.dumirc.ts index 357130d..99b2270 100644 --- a/example/.dumirc.ts +++ b/example/.dumirc.ts @@ -69,6 +69,9 @@ export default defineConfig({ define: { 'process.env': process.env, }, + base: isProduction ? '/dumi-theme-yunti/' : '/', + publicPath: '/dumi-theme-yunti/', + outputPath: './dist/dumi-theme-yunti/', favicons: ['https://avatars.githubusercontent.com/u/148947838?s=64&v=4'], locales: [ { id: 'zh-CN', name: '中文', suffix: '' },