Skip to content

Commit da1f460

Browse files
🩹 [Patch]: Merge Docs jobs into one (#136)
## Description This pull request includes significant updates to the CI/CD workflow configurations in `.github/workflows/CI.yml` and `.github/workflows/workflow.yml`. The changes streamline the build process, add new steps for documentation handling, and remove redundant jobs. Key changes include: ### Workflow Simplification: * Removed the `needs` dependencies and conditional checks from the `BuildModule` job, simplifying the workflow (`.github/workflows/CI.yml`, [[1]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8L199-L203); `.github/workflows/workflow.yml`, [[2]](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1L206-L210). ### Documentation Handling: * Added steps to commit all changes and lint documentation using the `super-linter` action (`.github/workflows/CI.yml`, [[1]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R262-R372); `.github/workflows/workflow.yml`, [[2]](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1R269-R379). * Introduced steps to install `mkdocs-material` and related plugins, structure the site, and build the documentation site (`.github/workflows/CI.yml`, [[1]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R262-R372); `.github/workflows/workflow.yml`, [[2]](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1R269-R379). ### Artifact Management: * Added steps to configure GitHub Pages and upload the built site as an artifact (`.github/workflows/CI.yml`, [[1]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R262-R372); `.github/workflows/workflow.yml`, [[2]](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1R269-R379). ### Fetch Depth Configuration: * Updated the `checkout` action to use `fetch-depth: 0` to ensure the full history is available (`.github/workflows/CI.yml`, [[1]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R235-R236) [[2]](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R384-R385); `.github/workflows/workflow.yml`, [[3]](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1R242-R243) [[4]](diffhunk://#diff-126bf89616b7daa3d14ebc882ad18666aaf1c3dae888c4ba306a66ec80758bc1R269-R379). ### Removal of Redundant Jobs: * Removed the `LintDocs` and `BuildSite` jobs, consolidating their steps into the main workflow (`.github/workflows/CI.yml`, [.github/workflows/CI.ymlL545-L709](diffhunk://#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8L545-L709)). These changes aim to enhance the efficiency and clarity of the CI/CD workflows by reducing complexity and adding necessary steps for documentation management. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 30bf28d commit da1f460

22 files changed

+231
-1609
lines changed

.github/workflows/CI.yml

Lines changed: 115 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ jobs:
196196

197197
BuildModule:
198198
name: Build module
199-
if: ${{ contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-ubuntu-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-macos-latest.result) && contains(fromJson('["success", "skipped"]'), needs.TestSourceCode-pwsh-windows-latest.result) && !cancelled() }}
200-
needs:
201-
- TestSourceCode-pwsh-ubuntu-latest
202-
- TestSourceCode-pwsh-macos-latest
203-
- TestSourceCode-pwsh-windows-latest
204199
runs-on: ubuntu-latest
205200
steps:
206201
- name: Checkout Code
@@ -237,6 +232,8 @@ jobs:
237232
steps:
238233
- name: Checkout Code
239234
uses: actions/checkout@v4
235+
with:
236+
fetch-depth: 0
240237

241238
- name: Debug
242239
if: ${{ inputs.Debug }}
@@ -262,6 +259,117 @@ jobs:
262259
Verbose: ${{ inputs.Verbose }}
263260
Version: ${{ inputs.Version }}
264261

262+
- name: Commit all changes
263+
run: |
264+
git add .
265+
git commit -m 'Update documentation'
266+
267+
- name: Lint documentation
268+
uses: super-linter/super-linter/slim@latest
269+
env:
270+
FILTER_REGEX_INCLUDE: '${{ inputs.DocsOutputPath }}/**'
271+
DEFAULT_BRANCH: main
272+
DEFAULT_WORKSPACE: ${{ github.workspace }}
273+
ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true
274+
GITHUB_TOKEN: ${{ github.token }}
275+
RUN_LOCAL: true
276+
VALIDATE_ALL_CODEBASE: true
277+
VALIDATE_JSCPD: false
278+
VALIDATE_MARKDOWN_PRETTIER: false
279+
VALIDATE_YAML_PRETTIER: false
280+
VALIDATE_JSON_PRETTIER: false
281+
VALIDATE_GITLEAKS: false
282+
283+
- uses: actions/configure-pages@v5
284+
285+
- name: Install mkdoks-material
286+
shell: pwsh
287+
run: |
288+
pip install mkdocs-material
289+
pip install mkdocs-git-authors-plugin
290+
pip install mkdocs-git-revision-date-localized-plugin
291+
pip install mkdocs-git-committers-plugin-2
292+
293+
- name: Structure site
294+
uses: PSModule/GitHub-Script@v1
295+
with:
296+
Debug: ${{ inputs.Debug }}
297+
Prerelease: ${{ inputs.Prerelease }}
298+
Verbose: ${{ inputs.Verbose }}
299+
Version: ${{ inputs.Version }}
300+
Script: |
301+
New-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -ItemType Directory -Force
302+
Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force
303+
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
304+
$ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}'
305+
$SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}'
306+
307+
LogGroup "Get folderstructure" {
308+
Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object
309+
}
310+
311+
$functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item
312+
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
313+
$fileName = $_.Name
314+
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
315+
LogGroup " - [$fileName] - [$hash]" {
316+
Show-FileContent -Path $_
317+
}
318+
}
319+
320+
LogGroup 'Build docs - Process about topics' {
321+
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
322+
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
323+
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
324+
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
325+
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
326+
}
327+
328+
LogGroup 'Build docs - Copy icon to assets' {
329+
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
330+
$null = New-Item -Path $assetsFolderPath -ItemType Directory -Force
331+
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
332+
$iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
333+
Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose
334+
}
335+
336+
LogGroup 'Build docs - Copy readme.md' {
337+
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
338+
$readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
339+
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
340+
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
341+
}
342+
343+
LogGroup 'Build docs - Create mkdocs.yml' {
344+
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
345+
# This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
346+
$mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
347+
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
348+
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
349+
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
350+
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
351+
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
352+
Show-FileContent -Path $mkdocsTargetPath
353+
}
354+
355+
- name: Debug File system
356+
shell: pwsh
357+
run: |
358+
Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object
359+
360+
- name: Build mkdocs-material project
361+
working-directory: ${{ inputs.SiteOutputPath }}
362+
shell: pwsh
363+
run: |
364+
Start-LogGroup 'Build docs - mkdocs build - content'
365+
Show-FileContent -Path mkdocs.yml
366+
Stop-LogGroup
367+
Start-LogGroup 'Build docs - mkdocs build'
368+
mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site
369+
Stop-LogGroup
370+
371+
- uses: actions/upload-pages-artifact@v3
372+
265373
# This is necessary as there is no way to get output from a matrix job
266374
TestModule-pwsh-ubuntu-latest:
267375
name: Test module (pwsh, ubuntu-latest)
@@ -273,6 +381,8 @@ jobs:
273381
steps:
274382
- name: Checkout Code
275383
uses: actions/checkout@v4
384+
with:
385+
fetch-depth: 0
276386

277387
- name: Debug
278388
if: ${{ inputs.Debug }}
@@ -542,168 +652,3 @@ jobs:
542652
if-no-files-found: error
543653
retention-days: 1
544654
overwrite: true
545-
546-
LintDocs:
547-
name: Lint documentation
548-
if: ${{ needs.BuildDocs.result == 'success' && !cancelled() }}
549-
needs: BuildDocs
550-
runs-on: ubuntu-latest
551-
steps:
552-
- name: Checkout Code
553-
uses: actions/checkout@v4
554-
with:
555-
fetch-depth: 0
556-
ref: ${{ github.event.pull_request.head.sha }}
557-
558-
- name: Debug
559-
if: ${{ inputs.Debug }}
560-
uses: PSModule/Debug@v0
561-
562-
- name: Download docs artifact
563-
uses: actions/download-artifact@v4
564-
with:
565-
name: docs
566-
path: ${{ github.workspace }}
567-
568-
- name: Commit docs for linting
569-
shell: pwsh
570-
run: |
571-
git config --global user.name "Github Actions"
572-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
573-
git add .
574-
git commit -m "Update documentation"
575-
576-
- name: Lint documentation
577-
uses: super-linter/super-linter/slim@latest
578-
env:
579-
DEFAULT_BRANCH: main
580-
DEFAULT_WORKSPACE: ${{ github.workspace }}
581-
ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true
582-
GITHUB_TOKEN: ${{ github.token }}
583-
RUN_LOCAL: true
584-
VALIDATE_ALL_CODEBASE: false
585-
VALIDATE_JSCPD: false
586-
VALIDATE_MARKDOWN_PRETTIER: false
587-
VALIDATE_YAML_PRETTIER: false
588-
VALIDATE_GITLEAKS: false
589-
590-
BuildSite:
591-
name: Build Site
592-
if: ${{ inputs.PublishDocs && needs.LintDocs.result == 'success' && !cancelled() }}
593-
needs: LintDocs
594-
runs-on: ubuntu-latest
595-
steps:
596-
- name: Checkout Code
597-
uses: actions/checkout@v4
598-
with:
599-
fetch-depth: 0
600-
ref: ${{ github.event.pull_request.head.sha }}
601-
602-
- name: Debug
603-
if: ${{ inputs.Debug }}
604-
uses: PSModule/Debug@v0
605-
606-
- name: Initialize environment
607-
uses: PSModule/Initialize-PSModule@v1
608-
with:
609-
Debug: ${{ inputs.Debug }}
610-
Prerelease: ${{ inputs.Prerelease }}
611-
Verbose: ${{ inputs.Verbose }}
612-
Version: ${{ inputs.Version }}
613-
614-
- name: Download docs artifact
615-
uses: actions/download-artifact@v4
616-
with:
617-
name: docs
618-
path: '${{ inputs.SiteOutputPath }}/docs/Functions'
619-
620-
- name: Debug
621-
uses: PSModule/Debug@v0
622-
623-
- uses: actions/configure-pages@v5
624-
625-
- name: Install mkdoks-material
626-
shell: pwsh
627-
run: |
628-
pip install mkdocs-material
629-
pip install mkdocs-git-authors-plugin
630-
pip install mkdocs-git-revision-date-localized-plugin
631-
pip install mkdocs-git-committers-plugin-2
632-
633-
- name: Structure site
634-
uses: PSModule/GitHub-Script@v1
635-
with:
636-
Debug: ${{ inputs.Debug }}
637-
Prerelease: ${{ inputs.Prerelease }}
638-
Verbose: ${{ inputs.Verbose }}
639-
Version: ${{ inputs.Version }}
640-
Script: |
641-
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
642-
$ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}'
643-
$SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}'
644-
645-
$functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item
646-
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
647-
$fileName = $_.Name
648-
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
649-
LogGroup " - [$fileName] - [$hash]" {
650-
Show-FileContent -Path $_
651-
}
652-
}
653-
654-
LogGroup 'Build docs - Process about topics' {
655-
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
656-
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
657-
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
658-
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
659-
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
660-
}
661-
662-
LogGroup 'Build docs - Copy icon to assets' {
663-
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
664-
$null = New-Item -Path $assetsFolderPath -ItemType Directory -Force
665-
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
666-
$iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
667-
Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose
668-
}
669-
670-
LogGroup 'Build docs - Copy readme.md' {
671-
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
672-
$readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
673-
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
674-
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
675-
}
676-
677-
LogGroup 'Build docs - Create mkdocs.yml' {
678-
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
679-
# This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
680-
$mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
681-
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
682-
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
683-
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
684-
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
685-
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
686-
Show-FileContent -Path $mkdocsTargetPath
687-
}
688-
689-
- name: Debug
690-
uses: PSModule/Debug@v0
691-
692-
- name: Build mkdocs-material project
693-
uses: PSModule/GitHub-Script@v1
694-
with:
695-
WorkingDirectory: ${{ inputs.SiteOutputPath }}
696-
Debug: ${{ inputs.Debug }}
697-
Prerelease: ${{ inputs.Prerelease }}
698-
Verbose: ${{ inputs.Verbose }}
699-
Version: ${{ inputs.Version }}
700-
Script: |
701-
LogGroup 'Build docs - mkdocs build - content' {
702-
Show-FileContent -Path mkdocs.yml
703-
}
704-
705-
LogGroup 'Build docs - mkdocs build' {
706-
mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site
707-
}
708-
709-
- uses: actions/upload-pages-artifact@v3

0 commit comments

Comments
 (0)