Skip to content

Commit

Permalink
Build docs on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Apr 4, 2024
1 parent 575ee0c commit 08e245c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 30 deletions.
43 changes: 14 additions & 29 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,48 +171,33 @@ jobs:
- uses: denoland/setup-deno@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/
- 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/[email protected]
with:
publish-dir: docs/_site
publish-dir: docs/.vitepress/dist
production-branch: main
github-token: ${{ github.token }}
enable-pull-request-comment: false
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"callouts",
"cfworker",
"codegen",
"deflist",
"Deno",
"denokv",
"dereferenceable",
Expand Down Expand Up @@ -69,6 +70,7 @@
"unfollow",
"unfollowing",
"urlpattern",
"vitepress",
"webfinger"
]
}
27 changes: 27 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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",
Expand All @@ -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: [
Expand Down Expand Up @@ -94,6 +120,7 @@ export default defineConfig({
href: "/assets/favicon-32x32.png",
},
],
...plausibleScript
],

cleanUrls: true,
Expand Down
Binary file modified docs/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 08e245c

Please sign in to comment.