Unverified Commit e39b6477 authored by Hong Minhee's avatar Hong Minhee
Browse files

Build docs on CI

parent 575ee0cf
Loading
Loading
Loading
Loading
+16 −31
Original line number Diff line number Diff line
@@ -168,51 +168,36 @@ jobs:
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
    - uses: actions/checkout@v4
    - uses: denoland/setup-deno@v1
    - uses: oven-sh/setup-bun@v1
      with:
        deno-version: v1.x
    - if: github.event_name == 'push' && github.ref_type == 'tag'
      run: |
        jq \
          --arg url "$UNSTABLE_DOCS_URL" \
          '.nav_links = [{"title":"Go to unstable","url":$url}] + .nav_links' \
          _data.json > _data.json.tmp
        mv _data.json.tmp _data.json
      env:
        UNSTABLE_DOCS_URL: ${{ vars.UNSTABLE_DOCS_URL }}
      working-directory: ${{ github.workspace }}/docs/
    - if: github.event_name != 'push' || github.ref_type != 'tag'
      run: |
        jq \
          --arg url "$STABLE_DOCS_URL" \
          '.nav_links = [{"title":"Go to stable","url":$url}] + .nav_links' \
          _data.json > _data.json.tmp
        mv _data.json.tmp _data.json
      env:
        STABLE_DOCS_URL: ${{ vars.STABLE_DOCS_URL }}
      working-directory: ${{ github.workspace }}/docs/
        bun-version: latest
    - run: |
        set -ex
        jq \
          --arg domain "$PLAUSIBLE_DOMAIN" \
          '.plausible_domain = $domain' \
          _data.json > _data.json.tmp
        mv _data.json.tmp _data.json
        bun install
        if [[ "$GITHUB_EVENT_NAME" = "push" && "$GITHUB_REF_TYPE" = "tag" ]]; then
          EXTRA_NAV_TEXT=Unstable \
          EXTRA_NAV_LINK="$UNSTABLE_DOCS_URL" \
          bun run build
        else
          EXTRA_NAV_TEXT=Stable \
          EXTRA_NAV_LINK="$STABLE_DOCS_URL" \
          bun run build
        fi
      env:
        PLAUSIBLE_DOMAIN: ${{ secrets.PLAUSIBLE_DOMAIN }}
      working-directory: ${{ github.workspace }}/docs/
    - run: deno task lume
        STABLE_DOCS_URL: ${{ vars.STABLE_DOCS_URL }}
        UNSTABLE_DOCS_URL: ${{ vars.UNSTABLE_DOCS_URL }}
      working-directory: ${{ github.workspace }}/docs/
    - uses: actions/upload-pages-artifact@v3
      with:
        path: docs/_site
        path: docs/.vitepress/dist
    - id: deployment
      if: github.event_name == 'push' && github.ref_type == 'tag'
      uses: actions/deploy-pages@v4
    - if: github.event_name == 'pull_request' || github.ref_type == 'branch'
      uses: nwtgck/actions-netlify@v3.0
      with:
        publish-dir: docs/_site
        publish-dir: docs/.vitepress/dist
        production-branch: main
        github-token: ${{ github.token }}
        enable-pull-request-comment: false
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
    "callouts",
    "cfworker",
    "codegen",
    "deflist",
    "Deno",
    "denokv",
    "dereferenceable",
@@ -69,6 +70,7 @@
    "unfollow",
    "unfollowing",
    "urlpattern",
    "vitepress",
    "webfinger"
  ]
}
+27 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ import { Presets, SingleBar } from "cli-progress";
import deflist from "markdown-it-deflist";
import footnote from "markdown-it-footnote";
import { jsrRef } from "markdown-it-jsr-ref";
import process from "node:process";
import { defineConfig } from "vitepress";

const progress = new SingleBar({}, Presets.shades_classic);
@@ -20,6 +21,30 @@ const jsrRefPlugin = await jsrRef({
  },
});

let extraNav: { text: string; link: string }[] = [];
if (process.env.EXTRA_NAV_TEXT && process.env.EXTRA_NAV_LINK) {
  extraNav = [
    {
      text: process.env.EXTRA_NAV_TEXT,
      link: process.env.EXTRA_NAV_LINK,
    },
  ];
}

let plausibleScript: [string, Record<string, string>][] = [];
if (process.env.PLAUSIBLE_DOMAIN) {
  plausibleScript = [
    [
      "script",
      {
        defer: "defer",
        "data-domain": process.env.PLAUSIBLE_DOMAIN,
        src: "https://plausible.io/js/plausible.js",
      },
    ],
  ];
}

export default defineConfig({
  title: "Fedify",
  description: "Fedify docs",
@@ -29,6 +54,7 @@ export default defineConfig({
      { text: "Home", link: "/" },
      { text: "Manual", link: "/manual.md", activeMatch: "/manual" },
      { text: "API reference", link: "https://jsr.io/@fedify/fedify" },
      ...extraNav
    ],

    sidebar: [
@@ -94,6 +120,7 @@ export default defineConfig({
        href: "/assets/favicon-32x32.png",
      },
    ],
    ...plausibleScript
  ],

  cleanUrls: true,
−19 B (52.9 KiB)

File changed.

No diff preview for this file type.

+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
    "cli-progress": "^3.12.0",
    "markdown-it-deflist": "^3.0.0",
    "markdown-it-footnote": "^4.0.0",
    "markdown-it-jsr-ref": "0.1.0-dev.11",
    "markdown-it-jsr-ref": "^0.1.0",
    "vitepress": "^1.0.2"
  },
  "scripts": {