Skip to content

Commit 023c47d

Browse files
committed
ci(docs): Add build-docs-jp yaml
1 parent 8a84566 commit 023c47d

1 file changed

Lines changed: 332 additions & 0 deletions

File tree

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
name: angular-docs-jp
2+
3+
# Equivalent to Azure DevOps CI trigger: refs/tags/*
4+
# NOTE: This workflow runs inside the JP docs repository.
5+
# It clones igniteui-angular at the resolved branch/tag, copies the JP docs
6+
# assets (typedoc/sassdoc) from this repo into the clone's i18nRepo/ folder,
7+
# and then runs all npm commands inside the clone.
8+
on:
9+
push:
10+
tags:
11+
- '*'
12+
# Allows manual runs with queue-time variable equivalents (same as ADO).
13+
workflow_dispatch:
14+
inputs:
15+
igniteuiAngularBranch:
16+
description: 'igniteui-angular branch/tag to clone (leave empty to auto-detect from current tag)'
17+
required: false
18+
default: ''
19+
isLatest:
20+
description: 'Override isLatest flag (leave empty to auto-detect)'
21+
required: false
22+
default: ''
23+
skipDeployment:
24+
description: 'Skip deployment (for testing only)'
25+
required: false
26+
type: boolean
27+
default: false
28+
29+
jobs:
30+
build-docs:
31+
runs-on: ubuntu-latest
32+
33+
outputs:
34+
productionDeployment: ${{ steps.check-deployment.outputs.productionDeployment }}
35+
runDeployment: ${{ steps.set-deploy-flag.outputs.runDeployment }}
36+
37+
steps:
38+
# -----------------------------------------------------------------------
39+
# Checkout the JP docs repository (this repo).
40+
- name: Checkout JP docs repository
41+
uses: actions/checkout@v4
42+
with:
43+
# Full history needed for git ls-remote tag sorting and git describe
44+
fetch-depth: 0
45+
46+
# -----------------------------------------------------------------------
47+
# Resolve whether deployment should run.
48+
# On a tag push, inputs is empty so skipDeployment is '' — deploy runs.
49+
# On workflow_dispatch, deploy runs unless skipDeployment checkbox is checked.
50+
- name: Set deployment flag
51+
id: set-deploy-flag
52+
shell: pwsh
53+
run: |
54+
$skip = '${{ inputs.skipDeployment }}' -eq 'true'
55+
$run = if ($skip) { 'false' } else { 'true' }
56+
Write-Host "runDeployment: $run"
57+
echo "runDeployment=$run" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
58+
59+
# -----------------------------------------------------------------------
60+
# Equivalent to: NodeTool@0 — Use Node 20.19.x
61+
- name: Use Node 20.19.x
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version: '20.19.x'
65+
66+
# -----------------------------------------------------------------------
67+
# Equivalent to: DutchWorkzToolsAllVariables@1 — show all build variables.
68+
# In the JP ADO pipeline this was step 2, immediately after NodeTool.
69+
- name: Show all build variables
70+
shell: pwsh
71+
run: |
72+
Write-Host '=== Environment Variables ==='
73+
Get-ChildItem Env: | Sort-Object Name | Format-Table Name, Value -AutoSize
74+
75+
# -----------------------------------------------------------------------
76+
# Generate a build version once, before NuGet pack steps.
77+
# ADO used build.buildnumber (e.g. "AngularDocs_20240101.1") and split on '_'.
78+
# GitHub Actions equivalent uses a date + run_number format.
79+
- name: Set BuildVersion
80+
shell: pwsh
81+
run: |
82+
$buildDate = Get-Date -Format "yyyyMMdd"
83+
$version = "$buildDate.${{ github.run_number }}"
84+
Write-Host "BuildVersion: $version"
85+
echo "BuildVersion=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
86+
87+
# -----------------------------------------------------------------------
88+
# Equivalent to: DeleteFiles@1 — Delete *.nupkg and the igniteui-angular clone dir.
89+
- name: Delete files (*.nupkg, igniteui-angular clone)
90+
shell: pwsh
91+
run: |
92+
Get-ChildItem -Path '${{ github.workspace }}' -Filter '*.nupkg' -File |
93+
Remove-Item -Force -ErrorAction SilentlyContinue
94+
if (Test-Path '${{ github.workspace }}/igniteui-angular') {
95+
Remove-Item '${{ github.workspace }}/igniteui-angular' -Recurse -Force
96+
}
97+
98+
# -----------------------------------------------------------------------
99+
# Equivalent to: 'Extract the tag from repo' powershell step.
100+
# When triggered by a tag push, github.ref_name already contains the tag name.
101+
# Also resolves igniteuiAngularBranch: falls back to curTag when not provided,
102+
# matching the ADO pipeline's: if(-not "$(igniteuiAngularBranch)") { set to $tag }
103+
- name: Extract the tag and resolve igniteuiAngularBranch
104+
shell: pwsh
105+
run: |
106+
$fullTag = '${{ github.ref_name }}'
107+
$split = $fullTag -split '-'
108+
$tag = $split[0]
109+
Write-Host "curTag: $tag"
110+
Write-Host "fullTag: $fullTag"
111+
echo "curTag=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
112+
echo "fullTag=$fullTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
113+
114+
# Resolve igniteuiAngularBranch — use the manual input when provided,
115+
# otherwise default to the current tag (same logic as ADO queue-time variable).
116+
$angularBranch = '${{ inputs.igniteuiAngularBranch }}'
117+
if (-not $angularBranch) { $angularBranch = $tag }
118+
Write-Host "igniteuiAngularBranch: $angularBranch"
119+
echo "igniteuiAngularBranch=$angularBranch" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
120+
121+
# -----------------------------------------------------------------------
122+
# Equivalent to: ADO pipeline variable variables: isLatest: 'true'
123+
# JP pipeline hardcodes isLatest=true; the workflow_dispatch input allows
124+
# overriding it at queue time (same as changing the ADO variable before queuing).
125+
- name: Set isLatest
126+
shell: pwsh
127+
run: |
128+
$value = '${{ inputs.isLatest }}'
129+
if (-not $value) { $value = 'true' }
130+
Write-Host "isLatest: $value"
131+
echo "isLatest=$value" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
132+
133+
# -----------------------------------------------------------------------
134+
# Equivalent to: script — clone igniteui-angular at the resolved branch/tag.
135+
# In ADO this ran from Build.SourcesDirectory (the JP docs repo root),
136+
# producing a sibling "igniteui-angular" folder — replicated exactly here.
137+
- name: Clone igniteui-angular
138+
run: |
139+
git clone https://github.com/IgniteUI/igniteui-angular "igniteui-angular" \
140+
-b "${{ env.igniteuiAngularBranch }}" --depth 1
141+
working-directory: ${{ github.workspace }}
142+
143+
# -----------------------------------------------------------------------
144+
# Equivalent to: Npm@1 — npm cache clean --force (in cloned repo)
145+
- name: npm cache clean --force
146+
run: npm cache clean --force
147+
working-directory: ${{ github.workspace }}/igniteui-angular
148+
149+
# Equivalent to: Npm@1 — npm ci (in cloned repo)
150+
- name: npm ci
151+
run: npm ci --force
152+
working-directory: ${{ github.workspace }}/igniteui-angular
153+
154+
# Equivalent to: Npm@1 — npm run build:lib (in cloned repo)
155+
- name: npm run build:lib
156+
run: npm run build:lib
157+
working-directory: ${{ github.workspace }}/igniteui-angular
158+
159+
# -----------------------------------------------------------------------
160+
# JP-specific: Copy typedoc/sassdoc assets FROM this JP docs repo
161+
# INTO the cloned igniteui-angular's i18nRepo/ folder.
162+
# Equivalent to the two CopyFiles@2 tasks that copy:
163+
# $(Build.SourcesDirectory)\typedoc → igniteui-angular\i18nRepo\typedoc
164+
# $(Build.SourcesDirectory)\sassdoc → igniteui-angular\i18nRepo\sassdoc
165+
- name: Copy typedoc assets to igniteui-angular/i18nRepo
166+
shell: pwsh
167+
run: |
168+
$target = '${{ github.workspace }}/igniteui-angular/i18nRepo/typedoc'
169+
New-Item -ItemType Directory -Force -Path $target | Out-Null
170+
if (Test-Path '${{ github.workspace }}/typedoc') {
171+
Copy-Item -Path '${{ github.workspace }}/typedoc/*' -Destination $target -Recurse -Force
172+
}
173+
174+
- name: Copy sassdoc assets to igniteui-angular/i18nRepo
175+
shell: pwsh
176+
run: |
177+
$target = '${{ github.workspace }}/igniteui-angular/i18nRepo/sassdoc'
178+
New-Item -ItemType Directory -Force -Path $target | Out-Null
179+
if (Test-Path '${{ github.workspace }}/sassdoc') {
180+
Copy-Item -Path '${{ github.workspace }}/sassdoc/*' -Destination $target -Recurse -Force
181+
}
182+
183+
# -----------------------------------------------------------------------
184+
# ---- STAGING DOCS BUILD ---------------------------------------------
185+
# -----------------------------------------------------------------------
186+
187+
# Equivalent to: Npm@1 — npm run build:typedoc:ja:staging
188+
- name: npm run build:typedoc (staging)
189+
run: npm run build:typedoc:ja:staging
190+
working-directory: ${{ github.workspace }}/igniteui-angular
191+
192+
# Equivalent to: Npm@1 — npm run build:sassdoc:ja:staging
193+
- name: npm run build:sassdoc (staging)
194+
run: npm run build:sassdoc:ja:staging
195+
working-directory: ${{ github.workspace }}/igniteui-angular
196+
197+
# Equivalent to: powershell — patch angularDocsPostDeploy.ps1 with branch/isLatest values,
198+
# then CopyFiles@2 + rename — all operating inside the cloned igniteui-angular folder.
199+
# Note: ADO replaces VariableValue with igniteuiAngularBranch (not curTag).
200+
- name: Update PostDeploy.ps1 vars (staging)
201+
shell: pwsh
202+
run: |
203+
$filePath = '${{ github.workspace }}/igniteui-angular/angularDocsPostDeploy.ps1'
204+
((Get-Content -Path $filePath -Raw) -replace 'VariableValue', "$env:igniteuiAngularBranch") |
205+
Set-Content -Path $filePath
206+
((Get-Content -Path $filePath -Raw) -replace 'VariableIsLatest', "$env:isLatest") |
207+
Set-Content -Path $filePath
208+
209+
- name: Copy angularDocsPostDeploy.ps1 to dist (staging)
210+
shell: pwsh
211+
run: |
212+
$targetDir = '${{ github.workspace }}/igniteui-angular/dist/igniteui-angular/docs'
213+
New-Item -ItemType Directory -Force -Path $targetDir | Out-Null
214+
Copy-Item -Path '${{ github.workspace }}/igniteui-angular/angularDocsPostDeploy.ps1' `
215+
-Destination $targetDir -Force
216+
217+
- name: Rename PostDeploy.ps1 (staging)
218+
shell: pwsh
219+
run: |
220+
Rename-Item `
221+
-Path '${{ github.workspace }}/igniteui-angular/dist/igniteui-angular/docs/angularDocsPostDeploy.ps1' `
222+
-NewName 'PostDeploy.ps1'
223+
224+
# Upload the staging docs as a workflow artifact for the deploy job
225+
- name: Upload staging artifact
226+
uses: actions/upload-artifact@v4
227+
with:
228+
name: angularDocsJP-staging
229+
path: igniteui-angular/dist/igniteui-angular/docs/
230+
231+
# -----------------------------------------------------------------------
232+
# ---- PRODUCTION DOCS BUILD ------------------------------------------
233+
# -----------------------------------------------------------------------
234+
235+
# Equivalent to: Npm@1 — npm run build:typedoc:ja:production
236+
- name: npm run build:typedoc (production)
237+
run: npm run build:typedoc:ja:production
238+
working-directory: ${{ github.workspace }}/igniteui-angular
239+
240+
# Equivalent to: Npm@1 — npm run build:sassdoc:ja:production
241+
- name: npm run build:sassdoc (production)
242+
run: npm run build:sassdoc:ja:production
243+
working-directory: ${{ github.workspace }}/igniteui-angular
244+
245+
# Equivalent to: DeleteFiles@1 — Delete PostDeploy.ps1 from dist (prod re-uses same dist dir)
246+
- name: Delete PostDeploy.ps1 from dist folder
247+
shell: pwsh
248+
run: |
249+
Remove-Item `
250+
-Path '${{ github.workspace }}/igniteui-angular/dist/igniteui-angular/docs/PostDeploy.ps1' `
251+
-Force -ErrorAction SilentlyContinue
252+
253+
# Equivalent to: CopyFiles@2 + rename — prod variant uses isLatestProd.
254+
# Note: ADO replaces VariableValue with igniteuiAngularBranch (not curTag).
255+
- name: Copy angularDocsPostDeploy.ps1 to dist (production)
256+
shell: pwsh
257+
run: |
258+
Copy-Item -Path '${{ github.workspace }}/igniteui-angular/angularDocsPostDeploy.ps1' `
259+
-Destination '${{ github.workspace }}/igniteui-angular/dist/igniteui-angular/docs' -Force
260+
261+
- name: Update PostDeploy.ps1 vars (production)
262+
shell: pwsh
263+
run: |
264+
$filePath = '${{ github.workspace }}/igniteui-angular/dist/igniteui-angular/docs/angularDocsPostDeploy.ps1'
265+
((Get-Content -Path $filePath -Raw) -replace 'VariableValue', "$env:igniteuiAngularBranch") |
266+
Set-Content -Path $filePath
267+
((Get-Content -Path $filePath -Raw) -replace 'VariableIsLatest', "$env:isLatest") |
268+
Set-Content -Path $filePath
269+
270+
- name: Rename PostDeploy.ps1 (production)
271+
shell: pwsh
272+
run: |
273+
Rename-Item `
274+
-Path '${{ github.workspace }}/igniteui-angular/dist/igniteui-angular/docs/angularDocsPostDeploy.ps1' `
275+
-NewName 'PostDeploy.ps1'
276+
277+
# Upload the production docs as a workflow artifact for the deploy job
278+
- name: Upload production artifact
279+
uses: actions/upload-artifact@v4
280+
with:
281+
name: angularDocsJP-production
282+
path: igniteui-angular/dist/igniteui-angular/docs/
283+
284+
# -----------------------------------------------------------------------
285+
# Determine whether this tag is production-eligible (no alpha/beta/rc suffix).
286+
# Result is exposed as a job output so the deploy-production job can condition on it.
287+
- name: Check tag and set ProductionDeployment variable
288+
id: check-deployment
289+
shell: pwsh
290+
run: |
291+
$branchName = "${{ github.ref_name }}".ToLower()
292+
$shouldDeploy = -not $branchName.Contains('alpha') `
293+
-and -not $branchName.Contains('beta') `
294+
-and -not $branchName.Contains('rc')
295+
Write-Host "ProductionDeployment: $shouldDeploy"
296+
echo "productionDeployment=$shouldDeploy" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
297+
298+
# ---------------------------------------------------------------------------
299+
# Deploy staging docs to IIS via MSDeploy.
300+
# TODO: restore 'uses: IgniteUI/igniteui-actions/.github/workflows/deploy.yml@master'
301+
# once cross-repo access is confirmed.
302+
deploy-staging:
303+
needs: build-docs
304+
if: needs.build-docs.outputs.runDeployment == 'true'
305+
runs-on: ubuntu-latest
306+
steps:
307+
- name: Download staging artifact
308+
uses: actions/download-artifact@v4
309+
with:
310+
name: angularDocsJP-staging
311+
path: dist/igniteui-angular/docs/
312+
313+
- name: Deploy staging (placeholder)
314+
run: echo "TODO - deploy staging artifact to IIS (run-id ${{ github.run_id }})"
315+
316+
# ---------------------------------------------------------------------------
317+
# Deploy production docs — only on CI push of a non-pre-release tag.
318+
# TODO: restore 'uses: IgniteUI/igniteui-actions/.github/workflows/deploy.yml@master'
319+
# once cross-repo access is confirmed.
320+
deploy-production:
321+
needs: build-docs
322+
if: github.event_name == 'push' && needs.build-docs.outputs.productionDeployment == 'True'
323+
runs-on: ubuntu-latest
324+
steps:
325+
- name: Download production artifact
326+
uses: actions/download-artifact@v4
327+
with:
328+
name: angularDocsJP-production
329+
path: dist/igniteui-angular/docs/
330+
331+
- name: Deploy production (placeholder)
332+
run: echo "TODO - deploy production artifact to IIS (run-id ${{ github.run_id }})"

0 commit comments

Comments
 (0)