Github Action to Deploy Docusaurus

Vichea Nath
2 min readSep 16, 2023

--

Docusaurus is an open-source documentation framework that helps you build and maintain documentation websites with ease. It is particularly popular among developers and technical writers for creating user-friendly and attractive documentation sites for software projects, libraries, APIs, and more.

I have completed my document and would like to share it with everyone. It is free and can be accessed from any website or system.

This blog doesn't teach you how to create or develop Docusaurus, only how to use GitHub Actions to deploy it for free.

1 . in your Docuaurus project create a file

.github/workflows/deploy.yml
on:
push:
branches:
- main # Change this to your default branch if it's different

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18 # Use Node.js 18 here

- name: Install dependencies
run: npm install

- name: Build site
run: npm run build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build # Change this if your build output directory is different

2. Go to GitHub project setting and click on Page

Select Deploy from a branch

Select branch gh-pages and /root

3. Look at the left menu click on Action menu and scroll down to Workflow permissions

Select Read and Write permission

You just develop your Docusaurus and push to your main branch git it will be build and update to your document

Happy build your document Thanks!

--

--