49 lines
1.2 KiB
YAML

name: Deploy Docusaurus Site
on:
push:
branches:
- main
jobs:
deploy:
runs-on: host
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
run: |
echo "Node version: $(node -v)"
echo "npm version: $(npm -v)"
- name: Install npm dependencies
run: npm ci
- name: Build static site
run: npm run build
- name: Deploy static files to nginx serving directory
run: |
# デプロイ先ディレクトリ(必要に応じて変更)
DEPLOY_DIR="/var/www/docusaurus/swallow-tech-notes"
# ディレクトリ作成(初回のみ)
sudo mkdir -p $DEPLOY_DIR
# 既存の静的ファイルを削除
sudo rm -rf $DEPLOY_DIR/*
# build フォルダ内の全ファイルを nginx のルートへコピー
sudo cp -R build/* $DEPLOY_DIR/
- name: Reload nginx service
run: sudo systemctl reload nginx
- name: Deployment complete
run: |
echo "✅ Deployment successful!"
echo "Site deployed to: $DEPLOY_DIR"