Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e43bf53
🩹 [Patch]: Enhance CI workflow with documentation linting and site bu…
MariusStorhaug Feb 13, 2025
dce833c
🩹 [Patch]: Update CI workflows to use dynamic DocsOutputPath and clea…
MariusStorhaug Feb 13, 2025
873b7b0
🩹 [Patch]: Fix condition for publishing documentation in CI workflow
MariusStorhaug Feb 13, 2025
749b4d5
🩹 [Patch]: Set fetch-depth to 0 in CI workflow for complete history r…
MariusStorhaug Feb 13, 2025
ae55446
🩹 [Patch]: Update synopsis in Set-PSModuleTest function to include UR…
MariusStorhaug Feb 13, 2025
14fe5a3
🩹 [Patch]: Migrate linter and CI workflows to new directory structure
MariusStorhaug Feb 13, 2025
b8ab333
🩹 [Patch]: Add new CI and linter workflows with updated configurations
MariusStorhaug Feb 13, 2025
792fe2d
🩹 [Cleanup]: Remove obsolete documentation and test module files
MariusStorhaug Feb 13, 2025
0e2d0b6
🩹 [Patch]: Remove unnecessary conditions and dependencies from CI wor…
MariusStorhaug Feb 13, 2025
afc57da
🩹 [Patch]: Update CI workflow to set fetch-depth to 0 for complete hi…
MariusStorhaug Feb 13, 2025
f25ed37
🩹 [Cleanup]: Comment out DEFAULT_WORKSPACE in CI workflow configurations
MariusStorhaug Feb 13, 2025
a47f7b9
🩹 [Patch]: Enable codebase validation in CI workflows
MariusStorhaug Feb 13, 2025
02ce022
🩹 [Feature]: Add step to commit all code changes in CI workflows
MariusStorhaug Feb 13, 2025
0eb76d7
🩹 [Patch]: Update CI workflows to fetch base branch and remove commit…
MariusStorhaug Feb 13, 2025
13fa31b
🩹 [Cleanup]: Refactor CI workflows by removing unnecessary fetch step…
MariusStorhaug Feb 13, 2025
9d6f70f
🩹 [Cleanup]: Comment out FILTER_REGEX_INCLUDE in CI workflows to simp…
MariusStorhaug Feb 13, 2025
e567b3c
🩹 [Feature]: Enable debug mode for super-linter in CI workflows
MariusStorhaug Feb 13, 2025
ace4b64
🩹 [Feature]: Add step to commit all changes in CI workflows
MariusStorhaug Feb 13, 2025
23a8fba
🩹 [Documentation]: Update synopsis in Set-PSModuleTest function to cl…
MariusStorhaug Feb 13, 2025
2913e2c
🩹 [Cleanup]: Uncomment FILTER_REGEX_INCLUDE in CI workflows to enable…
MariusStorhaug Feb 13, 2025
42868db
🩹 [Fix]: Update FILTER_REGEX_INCLUDE in CI workflows to use dynamic D…
MariusStorhaug Feb 13, 2025
2a9123e
🩹 [Cleanup]: Remove debug mode and unnecessary ref in CI workflows
MariusStorhaug Feb 13, 2025
5fab08f
🩹 [Documentation]: Simplify synopsis in Set-PSModuleTest function and…
MariusStorhaug Feb 13, 2025
33b5b2c
🩹 [Documentation]: Update header format in SomethingElse.md for consi…
MariusStorhaug Feb 13, 2025
3f73d04
🩹 [Enhancement]: Add logging for folder structure retrieval in CI wor…
MariusStorhaug Feb 13, 2025
674747b
🩹 [Enhancement]: Create Functions directory and copy documentation fi…
MariusStorhaug Feb 13, 2025
9596ad4
🩹 [Cleanup]: Use double quotes for path variables in CI workflow scri…
MariusStorhaug Feb 13, 2025
aebd936
🩹 [Fix]: Update path for copying documentation files in CI workflows
MariusStorhaug Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
285 changes: 115 additions & 170 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ jobs:

BuildModule:
name: Build module
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() }}
needs:
- TestSourceCode-pwsh-ubuntu-latest
- TestSourceCode-pwsh-macos-latest
- TestSourceCode-pwsh-windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout Code
Expand Down Expand Up @@ -237,6 +232,8 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Debug
if: ${{ inputs.Debug }}
Expand All @@ -262,6 +259,117 @@ jobs:
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}

- name: Commit all changes
run: |
git add .
git commit -m 'Update documentation'

- name: Lint documentation
uses: super-linter/super-linter/slim@latest
env:
FILTER_REGEX_INCLUDE: '${{ inputs.DocsOutputPath }}/**'
DEFAULT_BRANCH: main
DEFAULT_WORKSPACE: ${{ github.workspace }}
ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true
GITHUB_TOKEN: ${{ github.token }}
RUN_LOCAL: true
VALIDATE_ALL_CODEBASE: true
VALIDATE_JSCPD: false
VALIDATE_MARKDOWN_PRETTIER: false
VALIDATE_YAML_PRETTIER: false
VALIDATE_JSON_PRETTIER: false
VALIDATE_GITLEAKS: false

- uses: actions/configure-pages@v5

- name: Install mkdoks-material
shell: pwsh
run: |
pip install mkdocs-material
pip install mkdocs-git-authors-plugin
pip install mkdocs-git-revision-date-localized-plugin
pip install mkdocs-git-committers-plugin-2

- name: Structure site
uses: PSModule/GitHub-Script@v1
with:
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
Script: |
New-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -ItemType Directory -Force
Copy-Item -Path "$env:GITHUB_WORKSPACE/${{ inputs.DocsOutputPath }}" -Destination "$env:GITHUB_WORKSPACE/${{ inputs.SiteOutputPath }}/docs/Functions" -Recurse -Force
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
$ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}'
$SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}'

LogGroup "Get folderstructure" {
Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object
}

$functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$fileName = $_.Name
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
LogGroup " - [$fileName] - [$hash]" {
Show-FileContent -Path $_
}
}

LogGroup 'Build docs - Process about topics' {
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
}

LogGroup 'Build docs - Copy icon to assets' {
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
$null = New-Item -Path $assetsFolderPath -ItemType Directory -Force
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose
}

LogGroup 'Build docs - Copy readme.md' {
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
}

LogGroup 'Build docs - Create mkdocs.yml' {
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
# This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
$mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
Show-FileContent -Path $mkdocsTargetPath
}

- name: Debug File system
shell: pwsh
run: |
Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object

- name: Build mkdocs-material project
working-directory: ${{ inputs.SiteOutputPath }}
shell: pwsh
run: |
Start-LogGroup 'Build docs - mkdocs build - content'
Show-FileContent -Path mkdocs.yml
Stop-LogGroup
Start-LogGroup 'Build docs - mkdocs build'
mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site
Stop-LogGroup

- uses: actions/upload-pages-artifact@v3

# This is necessary as there is no way to get output from a matrix job
TestModule-pwsh-ubuntu-latest:
name: Test module (pwsh, ubuntu-latest)
Expand All @@ -273,6 +381,8 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Debug
if: ${{ inputs.Debug }}
Expand Down Expand Up @@ -542,168 +652,3 @@ jobs:
if-no-files-found: error
retention-days: 1
overwrite: true

LintDocs:
name: Lint documentation
if: ${{ needs.BuildDocs.result == 'success' && !cancelled() }}
needs: BuildDocs
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Debug
if: ${{ inputs.Debug }}
uses: PSModule/Debug@v0

- name: Download docs artifact
uses: actions/download-artifact@v4
with:
name: docs
path: ${{ github.workspace }}

- name: Commit docs for linting
shell: pwsh
run: |
git config --global user.name "Github Actions"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Update documentation"

- name: Lint documentation
uses: super-linter/super-linter/slim@latest
env:
DEFAULT_BRANCH: main
DEFAULT_WORKSPACE: ${{ github.workspace }}
ENABLE_GITHUB_ACTIONS_GROUP_TITLE: true
GITHUB_TOKEN: ${{ github.token }}
RUN_LOCAL: true
VALIDATE_ALL_CODEBASE: false
VALIDATE_JSCPD: false
VALIDATE_MARKDOWN_PRETTIER: false
VALIDATE_YAML_PRETTIER: false
VALIDATE_GITLEAKS: false

BuildSite:
name: Build Site
if: ${{ inputs.PublishDocs && needs.LintDocs.result == 'success' && !cancelled() }}
needs: LintDocs
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Debug
if: ${{ inputs.Debug }}
uses: PSModule/Debug@v0

- name: Initialize environment
uses: PSModule/Initialize-PSModule@v1
with:
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}

- name: Download docs artifact
uses: actions/download-artifact@v4
with:
name: docs
path: '${{ inputs.SiteOutputPath }}/docs/Functions'

- name: Debug
uses: PSModule/Debug@v0

- uses: actions/configure-pages@v5

- name: Install mkdoks-material
shell: pwsh
run: |
pip install mkdocs-material
pip install mkdocs-git-authors-plugin
pip install mkdocs-git-revision-date-localized-plugin
pip install mkdocs-git-committers-plugin-2

- name: Structure site
uses: PSModule/GitHub-Script@v1
with:
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
Script: |
$moduleName = [string]::IsNullOrEmpty('${{ inputs.Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ inputs.Name }}'
$ModuleSourcePath = Join-Path $PWD -ChildPath '${{ inputs.Path }}'
$SiteOutputPath = Join-Path $PWD -ChildPath '${{ inputs.SiteOutputPath }}'

$functionDocsFolder = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Functions' | Get-Item
Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
$fileName = $_.Name
$hash = (Get-FileHash -Path $_.FullName -Algorithm SHA256).Hash
LogGroup " - [$fileName] - [$hash]" {
Show-FileContent -Path $_
}
}

LogGroup 'Build docs - Process about topics' {
$aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
$aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
$aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
}

LogGroup 'Build docs - Copy icon to assets' {
$assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
$null = New-Item -Path $assetsFolderPath -ItemType Directory -Force
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$iconPath = Join-Path -Path $rootPath -ChildPath 'icon\icon.png'
Copy-Item -Path $iconPath -Destination $assetsFolderPath -Force -Verbose
}

LogGroup 'Build docs - Copy readme.md' {
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
$readmePath = Join-Path -Path $rootPath -ChildPath 'README.md'
$readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
}

LogGroup 'Build docs - Create mkdocs.yml' {
$rootPath = Split-Path -Path $ModuleSourcePath -Parent
# This should be moved to an action so that we can use a default one, and not have to copy it from the repo.
$mkdocsSourcePath = Join-Path -Path $rootPath -ChildPath 'mkdocs.yml'
$mkdocsTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'mkdocs.yml'
$mkdocsContent = Get-Content -Path $mkdocsSourcePath -Raw
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
$mkdocsContent = $mkdocsContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
$mkdocsContent | Set-Content -Path $mkdocsTargetPath -Force
Show-FileContent -Path $mkdocsTargetPath
}

- name: Debug
uses: PSModule/Debug@v0

- name: Build mkdocs-material project
uses: PSModule/GitHub-Script@v1
with:
WorkingDirectory: ${{ inputs.SiteOutputPath }}
Debug: ${{ inputs.Debug }}
Prerelease: ${{ inputs.Prerelease }}
Verbose: ${{ inputs.Verbose }}
Version: ${{ inputs.Version }}
Script: |
LogGroup 'Build docs - mkdocs build - content' {
Show-FileContent -Path mkdocs.yml
}

LogGroup 'Build docs - mkdocs build' {
mkdocs build --config-file mkdocs.yml --site-dir ${{ github.workspace }}/_site
}

- uses: actions/upload-pages-artifact@v3
Loading