Some checks failed
Deploy triz-docs to civital server / build-and-deploy (push) Failing after 1h8m5s
101 lines
3.5 KiB
YAML
101 lines
3.5 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 conditional rmdir (was causing silent abort)
|
|
# - Prints CWD and directory listing so we can see
|
|
# exactly what npm ci is working with
|
|
# --------------------------------------------------
|
|
- name: Install dependencies
|
|
if: success()
|
|
shell: cmd
|
|
run: |
|
|
set PATH=%NODE_PATH%;%PATH%
|
|
cd /d "%WORKSPACE_DIR%"
|
|
echo [diag] Working dir: %CD%
|
|
echo [diag] Node: & node --version
|
|
echo [diag] npm: & npm --version
|
|
echo [diag] Files in workspace:
|
|
dir /B "%WORKSPACE_DIR%"
|
|
echo [diag] Running npm ci...
|
|
npm ci
|
|
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
|
|
echo [diag] npm ci done. Contents of node_modules\.bin:
|
|
dir /B "%WORKSPACE_DIR%\node_modules\.bin"
|
|
|
|
# --------------------------------------------------
|
|
# 4. Build
|
|
# Calls node directly — avoids .cmd resolution and
|
|
# PATH issues entirely. Works even if node_modules\.bin
|
|
# is not in PATH at all.
|
|
# --------------------------------------------------
|
|
- name: Build
|
|
if: success()
|
|
shell: cmd
|
|
run: |
|
|
set PATH=%NODE_PATH%;%PATH%
|
|
cd /d "%WORKSPACE_DIR%"
|
|
echo [diag] Starting build via node...
|
|
node "%WORKSPACE_DIR%\node_modules\@docusaurus\core\bin\docusaurus.js" build
|
|
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
|
|
echo [diag] Build output:
|
|
dir /B "%WORKSPACE_DIR%\build"
|
|
|
|
# --------------------------------------------------
|
|
# 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%" |