Skip to content

ci: add automatic deployment #1

ci: add automatic deployment

ci: add automatic deployment #1

name: Update GitHub Pages
on:
# Trigger the workflow on push to master/main branch
push:
branches:
- master
- main
# Allows manual triggering from the Actions tab
workflow_dispatch:
jobs:
update-gh-pages:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: '0' # Fetch all history so we can push to gh-pages
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22' # Specify the Node.js version you use
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build Docusaurus site
run: yarn build
- name: Checkout gh-pages branch
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git fetch origin gh-pages
git switch gh-pages
- name: Remove old site directory
run: rm -rf ./site
- name: Move build to site directory
run: mv ./build ./site
- name: Commit changes
run: |
TIMESTAMP=$(date +"%Y-%m-%d %H:%M")
git add site/*
git commit -m "Update site with new build - $TIMESTAMP"
- name: Push changes to gh-pages branch
run: git push origin gh-pages