Skip to main content

Docusaurus

npx create-docusaurus@latest docs classic --typescript

[2/5] Resolving packages...
warning @docusaurus/core > del > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning @docusaurus/core > webpack-dev-server > rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
warning @docusaurus/core > shelljs > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @docusaurus/core > del > rimraf > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @docusaurus/core > react-dev-utils > fork-ts-checker-webpack-plugin > glob@7.2.3: Glob versions prior to v9 are no longer supported
warning @docusaurus/core > shelljs > glob > inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning @docusaurus/core > react-dev-utils > fork-ts-checker-webpack-plugin > memfs@3.6.0: this will be v4
warning @docusaurus/core > webpack-dev-server > webpack-dev-middleware > memfs@3.6.0: this will be v4
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning "@docusaurus/core > react-loadable-ssr-addon-v5-slorber@1.0.1" has unmet peer dependency "react-loadable@*".
warning "@docusaurus/core > @docusaurus/mdx-loader > @mdx-js/mdx > recma-jsx > acorn-jsx@5.3.2" has unmet peer dependency "acorn@^6.0.0 || ^7.0.0 || ^8.0.0".
warning " > @mdx-js/react@3.1.0" has unmet peer dependency "@types/react@>=16".
warning "@docusaurus/preset-classic > @docusaurus/theme-search-algolia > @docsearch/react > @algolia/autocomplete-preset-algolia@1.17.7" has unmet peer dependency "@algolia/client-search@>= 4.9.1 < 6".
warning "@docusaurus/preset-classic > @docusaurus/theme-search-algolia > @docsearch/react > @algolia/autocomplete-core > @algolia/autocomplete-shared@1.17.7" has unmet peer dependency "@algolia/client-search@>= 4.9.1 < 6".
warning "@docusaurus/preset-classic > @docusaurus/theme-search-algolia > @docsearch/react > @algolia/autocomplete-core > @algolia/autocomplete-plugin-algolia-insights@1.17.7" has unmet peer dependency "search-insights@>= 1 < 3".
[5/5] Building fresh packages...
success Saved lockfile.
Done in 41.69s.
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
[SUCCESS] Created docs.
[INFO] Inside that directory, you can run several commands:

`yarn start`
Starts the development server.

`yarn build`
Bundles your website into static files for production.

`yarn serve`
Serves the built website locally.

`yarn deploy`
Publishes the website to GitHub pages.

We recommend that you begin by typing:

`cd docs`
`yarn start`

Deploy Automation to GitHub Pages

To automate the build process for your docs app (such as Docusaurus) and integrate it into your existing GitHub Actions workflow, you need to add a build step before deploying. Here's how you can modify your workflow:

  1. Check out the repository to access the code.
  2. Set up Node.js to ensure the environment can run your build.
  3. Install dependencies for the docs app.
  4. Build the docs app to generate the static files.
  5. Deploy the built files to GitHub Pages.

Here's an updated version of your workflow:

name: Build and Deploy Docs to GitHub Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16' # Ensure compatibility with your project

- name: Install dependencies
working-directory: ./docs
run: npm install

- name: Build Docs
working-directory: ./docs
run: npm run build # Replace with the correct build script from your package.json

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'docs/build' # Adjust path to point to your build output folder

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

Key Points

  • Node.js Setup: Ensure the Node.js version specified matches the requirements of your docs app. Adjust the node-version if needed.
  • Install and Build: This workflow navigates to the docs directory to install dependencies and run the build process. Ensure the npm run build command matches the script in your package.json, typically "build": "docusaurus build" for Docusaurus.
  • Artifact Path: Adjust the path parameter in the Upload artifact step to point to where your build output resides. For Docusaurus, the default is usually build inside the docs directory.
  • Environment: The setup assumes a Unix-based environment (Ubuntu). Adjust runs-on if you're targeting a different OS.

This configuration will automate building the docs app and deploy it upon every push to the main branch, or when manually triggered.