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

85 lines
2.8 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
steps:
# --------------------------------------------------
# 1. Clean slate — wipe any leftover from a previous run
# --------------------------------------------------
- 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 — token scoped to this step only
# to limit its exposure in the environment
# --------------------------------------------------
- name: Clone source code
if: success()
shell: cmd
env:
GIT_TOKEN: ${{ secrets.GITEAACTTOKEN }}
run: |
git clone --depth 1 --branch %BRANCH% http://ciRunner:%GIT_TOKEN%@%GIT_REPO_URL% "%WORKSPACE_DIR%"
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 3. Install exact dependency tree from lock file
# --------------------------------------------------
- name: Install dependencies
if: success()
shell: cmd
run: |
cd /d "%WORKSPACE_DIR%"
npm ci
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 4. Build Docusaurus static site
# --------------------------------------------------
- name: Build
if: success()
shell: cmd
run: |
cd /d "%WORKSPACE_DIR%"
npm run build
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
# --------------------------------------------------
# 5. Deploy — robocopy exit codes 0-7 are all success
# (bitmask of what changed: copied, skipped, etc.)
# --------------------------------------------------
- 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 — no source code left on the runner
# --------------------------------------------------
- name: Cleanup workspace
if: always()
shell: cmd
run: |
if exist "%WORKSPACE_DIR%" rmdir /S /Q "%WORKSPACE_DIR%"