diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 3a9393e..71df155 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -2,9 +2,10 @@ name: Deploy Docs on: push: - branches: [main] + branches: [main, develop] paths: - - 'website/**' + - ".github/workflows/deploy-docs.yml" + - "website/**" workflow_dispatch: permissions: @@ -13,27 +14,36 @@ permissions: id-token: write concurrency: - group: pages - cancel-in-progress: false + group: pages-${{ github.ref }} + cancel-in-progress: true jobs: build: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Configure GitHub Pages + id: pages + uses: actions/configure-pages@v5 + - uses: oven-sh/setup-bun@v2 with: bun-version: 1.1.38 - name: Install dependencies working-directory: website - run: bun install + run: bun install --frozen-lockfile - name: Build docs working-directory: website + env: + DOCS_BASE: ${{ steps.pages.outputs.base_path }} + DOCS_EDIT_BRANCH: ${{ github.ref_name }} run: bun run docs:build - uses: actions/upload-pages-artifact@v3 @@ -41,11 +51,15 @@ jobs: path: website/.vitepress/dist deploy: + if: github.ref_name == 'main' || github.ref_name == 'develop' environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} needs: build runs-on: ubuntu-latest + permissions: + pages: write + id-token: write steps: - name: Deploy to GitHub Pages id: deployment diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index 6ae81f6..0000000 --- a/netlify.toml +++ /dev/null @@ -1,7 +0,0 @@ -[build] - base = "website" - command = "bun run docs:build" - publish = ".vitepress/dist" - -[build.environment] - DOCS_BASE = "/" diff --git a/website/.vitepress/config.mts b/website/.vitepress/config.mts index 997a864..7d708f1 100644 --- a/website/.vitepress/config.mts +++ b/website/.vitepress/config.mts @@ -1,7 +1,16 @@ import { defineConfig } from 'vitepress' import { withMermaid } from 'vitepress-plugin-mermaid' -const docsBase = process.env.DOCS_BASE || '/mempalace/' +function normalizeBase(base?: string): string { + if (!base || base === '/') { + return '/' + } + + return base.endsWith('/') ? base : `${base}/` +} + +const docsBase = normalizeBase(process.env.DOCS_BASE || '/mempalace/') +const editBranch = process.env.DOCS_EDIT_BRANCH || 'main' export default withMermaid( defineConfig({ @@ -91,7 +100,7 @@ export default withMermaid( }, editLink: { - pattern: 'https://github.com/milla-jovovich/mempalace/edit/main/website/:path', + pattern: `https://github.com/milla-jovovich/mempalace/edit/${editBranch}/website/:path`, text: 'Edit this page on GitHub', }, },