54 lines
1.5 KiB
YAML
54 lines
1.5 KiB
YAML
name: Deploy Docusaurus
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: docker
|
|
container:
|
|
image: node:20-bookworm
|
|
# 👇 QUESTA È LA CHIAVE: Montiamo la cartella fisica del server dentro il container Node
|
|
options: --volume /opt/forgejo/sites/docs:/deploy/docs
|
|
#volumes:
|
|
# - /opt/forgejo/sites/docs:/deploy/docs
|
|
|
|
steps:
|
|
- name: Checkout del codice
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Cache Node Modules
|
|
id: cache-npm
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-node-
|
|
|
|
- name: Installazione Dipendenze
|
|
run: npm ci
|
|
|
|
- name: Build Docusaurus
|
|
run: |
|
|
export NODE_OPTIONS="--max-old-space-size=4096"
|
|
npm run build
|
|
|
|
- name: Pubblica sul Server
|
|
run: |
|
|
TARGET_DIR="/deploy/docs"
|
|
echo "Inizio deploy su $TARGET_DIR..."
|
|
|
|
# Pulisce la cartella di destinazione
|
|
# (Attenzione: rm -rf su cartella montata cancella i file reali sul server!)
|
|
rm -rf $TARGET_DIR/*
|
|
|
|
# Copia i nuovi file
|
|
cp -r build/* $TARGET_DIR/
|
|
|
|
# 👇 SICUREZZA PERMESSI: Assicuriamoci che Nginx possa leggerli
|
|
chmod -R 755 $TARGET_DIR
|
|
|
|
echo "Deploy completato con successo e permessi aggiornati!" |