Skip to content

Commit a52fd9b

Browse files
authored
Merge pull request #1 from nxtgrid/chore/add-github-pages-deploy
build for github pages
2 parents d6f17f8 + 6b1519b commit a52fd9b

2 files changed

Lines changed: 67 additions & 2 deletions

File tree

.github/workflows/deploy-pages.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy docs to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
env:
22+
DOCS_DEPLOY_TARGET: gh-pages
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 22
31+
cache: npm
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Build site
37+
run: npm run build
38+
39+
- name: Setup Pages
40+
uses: actions/configure-pages@v5
41+
42+
- name: Upload artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: ./build
46+
47+
deploy:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.deployment.outputs.page_url }}
53+
steps:
54+
- name: Deploy to GitHub Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v4

docusaurus.config.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ import type * as Preset from '@docusaurus/preset-classic';
44

55
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
66

7+
const deployTarget = process.env.DOCS_DEPLOY_TARGET ?? 'netlify';
8+
9+
const siteUrl =
10+
deployTarget === 'gh-pages'
11+
? 'https://nxtgrid.github.io'
12+
: 'https://docs.nxtgrid.co';
13+
14+
const siteBaseUrl = deployTarget === 'gh-pages' ? '/nxt-docs/' : '/';
15+
716
const config: Config = {
817
title: 'NXT Docs',
918
tagline: 'Unified documentation for NXT open-source software',
@@ -15,10 +24,10 @@ const config: Config = {
1524
},
1625

1726
// Set the production url of your site here
18-
url: 'https://docs.nxtgrid.co',
27+
url: siteUrl,
1928
// Set the /<baseUrl>/ pathname under which your site is served
2029
// For Netlify/custom domain root hosting, keep this as '/'
21-
baseUrl: '/',
30+
baseUrl: siteBaseUrl,
2231

2332
// GitHub pages deployment config.
2433
// If you aren't using GitHub pages, you don't need these.

0 commit comments

Comments
 (0)