triz-docs/.gitea/workflows/deploy.yml
Othmane Ataallah 57d4e73e55
Some checks failed
Deploy triz-docs to civital server / build-and-deploy (push) Failing after 1h8m6s
fix ci-cd
2026-04-28 11:57:24 +01:00

104 lines
3.6 KiB
YAML

name: Deploy triz-docs to civital server
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: serveurtest150
env:
GIT_REPO_URL: 145.239.66.197:3000/TrizTech/triz-docs.git
BRANCH: main
WORKSPACE_DIR: C:\CICD\workspace\triz-docs
DEPLOY_DIR: C:\inetpub\wwwroot\docs
NODE_PATH: C:\Program Files\nodejs
steps:
# --------------------------------------------------
# 1. Clean slate
# --------------------------------------------------
- name: Prepare workspace
shell: cmd
run: |
if exist "%WORKSPACE_DIR%" rmdir /S /Q "%WORKSPACE_DIR%"
mkdir "%WORKSPACE_DIR%"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 2. Shallow clone — credential helper disabled
# --------------------------------------------------
- name: Clone source code
if: success()
shell: cmd
env:
GIT_TOKEN: ${{ secrets.GITEAACTTOKEN }}
run: |
git -c credential.helper= clone --depth 1 --branch %BRANCH% http://ciRunner:%GIT_TOKEN%@%GIT_REPO_URL% "%WORKSPACE_DIR%"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 3. Install dependencies
# - No echo+command chaining with & (triggers runner's
# implicit error check on some Gitea act_runner versions)
# - npm install instead of npm ci: works even if
# package-lock.json is missing or outdated
# --------------------------------------------------
- name: Install dependencies
if: success()
shell: cmd
run: |
set PATH=%NODE_PATH%;%PATH%
cd /d "%WORKSPACE_DIR%"
echo [diag] Working dir:
echo %CD%
echo [diag] Node version:
node --version
echo [diag] npm version:
npm --version
echo [diag] package.json present:
if exist "package.json" (echo YES) else (echo NO - ABORTING && exit /b 1)
echo [diag] Running npm install...
npm install
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
echo [diag] Checking docusaurus installed:
if exist "node_modules\.bin\docusaurus.cmd" (echo YES) else (echo NO - ABORTING && exit /b 1)
echo [diag] Install complete.
# --------------------------------------------------
# 4. Build
# npx finds the local docusaurus binary automatically —
# no hardcoded paths, no PATH resolution needed
# --------------------------------------------------
- name: Build
if: success()
shell: cmd
run: |
set PATH=%NODE_PATH%;%PATH%
cd /d "%WORKSPACE_DIR%"
echo [diag] Starting Docusaurus build...
npx docusaurus build
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
echo [diag] Build complete.
# --------------------------------------------------
# 5. Deploy
# --------------------------------------------------
- name: Deploy
if: success()
shell: cmd
run: |
if not exist "%DEPLOY_DIR%" mkdir "%DEPLOY_DIR%"
robocopy "%WORKSPACE_DIR%\build" "%DEPLOY_DIR%" /E /PURGE /NFL /NDL /NJH /NJS
if %ERRORLEVEL% gtr 7 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 6. Always clean up
# --------------------------------------------------
- name: Cleanup workspace
if: always()
shell: cmd
run: |
if exist "%WORKSPACE_DIR%" rmdir /S /Q "%WORKSPACE_DIR%"