Skip to content

Commit

Permalink
Add CICD for nitro docs and enable posthog plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-service-account committed Nov 13, 2023
1 parent 2f6317a commit f58584a
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 1 deletion.
73 changes: 73 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Nitro Docs

on:
push:
branches:
- main
paths:
- 'docs/**'
pull_request:
branches:
- main
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install jq
uses: dcarbone/[email protected]

- name: Fill env vars
run: |
env_example_file=".env.example"
touch .env
while IFS= read -r line || [[ -n "$line" ]]; do
if [[ "$line" == *"="* ]]; then
var_name=$(echo $line | cut -d '=' -f 1)
echo $var_name
var_value="$(jq -r --arg key "$var_name" '.[$key]' <<< "$SECRETS")"
echo "$var_name=$var_value" >> .env
fi
done < "$env_example_file"
working-directory: docs
env:
SECRETS: '${{ toJson(secrets) }}'

- name: Install dependencies
run: yarn install
working-directory: docs
- name: Build website
run: sed -i '/process.env.DEBUG = namespaces;/c\// process.env.DEBUG = namespaces;' ./node_modules/debug/src/node.js && yarn build
working-directory: docs

- name: Add Custome Domain file
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
run: echo "${{ vars.DOCUSAURUS_DOMAIN }}" > ./docs/build/CNAME

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
publish_dir: ./docs/build
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*.pdb

# Kernel Module Compile Results
*.mod*
*.mod
*.cmd
.tmp_versions/
modules.order
Expand Down
2 changes: 2 additions & 0 deletions docs/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
POSTHOG_PROJECT_API_KEY=xxxx
POSTHOG_APP_URL=xxxx
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.env
10 changes: 10 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

require("dotenv").config();

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");

Expand Down Expand Up @@ -46,6 +48,14 @@ const config = {
},
};
},
[
"posthog-docusaurus",
{
apiKey: process.env.POSTHOG_PROJECT_API_KEY,
appUrl: process.env.POSTHOG_APP_URL, // optional
enableInDevelopment: false, // optional
},
],
],

// Only for react live
Expand Down
2 changes: 2 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
"axios": "^1.5.1",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.5",
"dotenv": "^16.3.1",
"js-yaml": "^4.1.0",
"postcss": "^8.4.30",
"posthog-docusaurus": "^2.0.0",
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
21 changes: 21 additions & 0 deletions docs/src/theme/Layout/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
html,
body {
height: 100%;
}

.mainWrapper {
flex: 1 0 auto;
display: flex;
flex-direction: column;
}

/* Docusaurus-specific utility class */
:global(.docusaurus-mt-lg) {
margin-top: 3rem;
}

:global(#__docusaurus) {
min-height: 100%;
display: flex;
flex-direction: column;
}
10 changes: 10 additions & 0 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4939,6 +4939,11 @@ dot-prop@^6.0.1:
dependencies:
is-obj "^2.0.0"

dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

duplexer3@^0.1.4:
version "0.1.5"
resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.5.tgz#0b5e4d7bad5de8901ea4440624c8e1d20099217e"
Expand Down Expand Up @@ -8970,6 +8975,11 @@ postcss@^8.3.11, postcss@^8.4.14, postcss@^8.4.17, postcss@^8.4.21, postcss@^8.4
picocolors "^1.0.0"
source-map-js "^1.0.2"

posthog-docusaurus@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/posthog-docusaurus/-/posthog-docusaurus-2.0.0.tgz#8b8ac890a2d780c8097a1a9766a3d24d2a1f1177"
integrity sha512-nDSTIhmH/Fexv347Gx6wBCE97Z+fZTj0p/gqVYAaolMwSdVuzwyFWcFA+aW9uzA5Y5hjzRwwKJJOrIv8smkYkA==

prepend-http@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
Expand Down

0 comments on commit f58584a

Please sign in to comment.