diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..7c049b358 --- /dev/null +++ b/.github/workflows/docs.yml @@ -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/install-jq-action@v2.0.1 + + - 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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index aec371ecf..f75df993e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,7 @@ *.pdb # Kernel Module Compile Results -*.mod* +*.mod *.cmd .tmp_versions/ modules.order diff --git a/docs/.env.example b/docs/.env.example new file mode 100644 index 000000000..6a9e9757c --- /dev/null +++ b/docs/.env.example @@ -0,0 +1,2 @@ +POSTHOG_PROJECT_API_KEY=xxxx +POSTHOG_APP_URL=xxxx \ No newline at end of file diff --git a/docs/.gitignore b/docs/.gitignore index b2d6de306..811400bb3 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -18,3 +18,4 @@ npm-debug.log* yarn-debug.log* yarn-error.log* +.env \ No newline at end of file diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js index 0ded06118..90884e843 100644 --- a/docs/docusaurus.config.js +++ b/docs/docusaurus.config.js @@ -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"); @@ -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 diff --git a/docs/package.json b/docs/package.json index dfc76f74b..9a122d340 100644 --- a/docs/package.json +++ b/docs/package.json @@ -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", diff --git a/docs/src/theme/Layout/styles.module.scss b/docs/src/theme/Layout/styles.module.scss new file mode 100644 index 000000000..63857592c --- /dev/null +++ b/docs/src/theme/Layout/styles.module.scss @@ -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; +} \ No newline at end of file diff --git a/docs/yarn.lock b/docs/yarn.lock index 8063e076b..3bea109c7 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -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" @@ -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"