triz-docs/.gitea/workflows/pushMainTo150.yml
Othmane Ataallah 1290f4a359
Some checks failed
Deploy triz-docs to civital server test / build-and-deploy (push) Failing after 1h8m5s
Deploy triz-docs to civital server / build-and-deploy (push) Failing after 1h8m6s
fix ci-cd
2026-04-28 11:13:46 +01:00

95 lines
3.2 KiB
YAML

name: Deploy triz-docs to civital server
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: serveurtest150
env:
# === PROJECT ===
GIT_REPO_URL: 145.239.66.197:3000/TrizTech/triz-docs.git
BRANCH: main
# === WORKSPACE ===
WORKSPACE_DIR: C:\CICD\workspace\triz-docs
DEPLOY_DIR: C:\inetpub\wwwroot\docs
# === NODE — adjust this path if your Node.js is installed elsewhere ===
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
# -c credential.helper= disables Git Credential Manager
# entirely for this command — credentials come from the URL only
# --------------------------------------------------
- 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
# PATH is extended here so npm is always found
# regardless of how the runner account was set up
# --------------------------------------------------
- name: Install dependencies
if: success()
shell: cmd
run: |
set PATH=%NODE_PATH%;%PATH%
cd /d "%WORKSPACE_DIR%"
node --version
npm --version
npm ci
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 4. Build Docusaurus static site
# --------------------------------------------------
- name: Build
if: success()
shell: cmd
run: |
set PATH=%NODE_PATH%;%PATH%
cd /d "%WORKSPACE_DIR%"
npm run build
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 5. Deploy
# /E = include subdirectories (even empty ones)
# /PURGE = remove destination files absent from source
# --------------------------------------------------
- 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%"