Tune remainder of Initialize-ADTModule for performance.
#2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://help.github.com/en/actions/automating-your-workflow-with-github-actions | |
| # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners | |
| # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners | |
| # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell | |
| # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions | |
| # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-powershell | |
| # https://github.com/actions/upload-artifact#where-does-the-upload-go | |
| name: PSAppDeployToolkit-Windows-PowerShell | |
| on: | |
| pull_request: | |
| push: | |
| permissions: | |
| id-token: write # Require write permission to Fetch an OIDC token. | |
| contents: read | |
| env: | |
| NUGET_PACKAGES: ${{ github.workspace }}\.nuget\packages | |
| jobs: | |
| test: | |
| name: Run Tests | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Display the path | |
| shell: powershell | |
| run: echo ${env:PATH} | |
| - name: Version Display | |
| shell: powershell | |
| run: $PSVersionTable | |
| # actions/setup-dotnet caching is unwieldy with multiple projects | |
| # https://github.com/NuGet/Home/issues/12409 | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.NUGET_PACKAGES }} | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Cache PowerShell modules | |
| uses: potatoqualitee/psmodulecache@v6.2.1 | |
| with: | |
| modules-to-cache: Pester:5.7.1, InvokeBuild:5.14.20, PSScriptAnalyzer:1.24.0, platyPS:0.14.2, Alt3.Docusaurus.Powershell:1.0.37 | |
| shell: powershell | |
| - name: NuGet Latest | |
| shell: powershell | |
| run: Install-PackageProvider -Name NuGet -Confirm:$false -Force -Verbose | |
| - name: PowerShellGet Latest | |
| shell: powershell | |
| run: Install-Module -Name PowerShellGet -Repository PSGallery -Force | |
| - name: Install AzureSignTool | |
| run: dotnet tool install --global azuresigntool | |
| - name: Azure Login | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/4.0.x' || github.ref == 'refs/heads/4.1.x' | |
| uses: azure/login@v2 | |
| with: | |
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
| - name: Test and Build | |
| shell: powershell | |
| run: Invoke-Build -File .\src\PSAppDeployToolkit.build.ps1 | |
| - name: Upload module | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: PSAppDeployToolkit_ModuleOnly | |
| path: .\src\Artifacts\Module | |
| if-no-files-found: error | |
| compression-level: 9 | |
| overwrite: true | |
| - name: Upload v3 module template | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: PSAppDeployToolkit_Template_v3 | |
| path: .\src\Artifacts\Template_v3 | |
| if-no-files-found: error | |
| compression-level: 9 | |
| overwrite: true | |
| - name: Upload v4 module template | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: PSAppDeployToolkit_Template_v4 | |
| path: .\src\Artifacts\Template_v4 | |
| if-no-files-found: error | |
| compression-level: 9 | |
| overwrite: true | |
| - name: Update Website Docs | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/4.0.x' || github.ref == 'refs/heads/4.1.x' | |
| shell: powershell | |
| env: | |
| API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} | |
| run: | | |
| # Perform initial setup. | |
| $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop | |
| Set-StrictMode -Version 3 | |
| # Clone the destination repo. | |
| $dstBnch = 'main' | |
| $dstRepo = "https://$env:API_TOKEN_GITHUB@github.com/$env:GITHUB_REPOSITORY_OWNER/website.git" | |
| $dstBase = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName()) | |
| $dstPath = ("$dstBase\docs\reference\functions", "$dstBase\versioned_docs\version-4.0.0\reference\functions")[$env:GITHUB_REF_NAME -match '4\.0\.x'] | |
| Write-Host -Object "Cloning destination repository, please wait..." | |
| git clone -b $dstBnch $dstRepo $dstBase | |
| if ($Global:LASTEXITCODE) | |
| { | |
| throw "The cloning of the destination repository failed." | |
| } | |
| # Update the docs from the source repo to the destination. | |
| Write-Host -Object "Updating the markdown files in destination repository." | |
| Remove-Item -Path "$dstPath\*" -Force -Confirm:$false | |
| Get-ChildItem -Path ".\src\Artifacts\Docusaurus\commands\*" -File | Copy-Item -Destination $dstPath | |
| # Change into the repository's directory. | |
| Push-Location -LiteralPath $dstBase | |
| # Add any changes that may exist. | |
| git add --all | |
| # Commit any changes if found. | |
| if (git diff --cached) | |
| { | |
| # Set up author details. | |
| git config user.email "$env:USERNAME@psappdeploytoolkit.com" | |
| git config user.name "PSAppDeployToolkit Action Workflow" | |
| # Do the commit. | |
| $commitMsg = "Commit of document changes from https://github.com/$env:GITHUB_REPOSITORY/commit/$env:GITHUB_SHA" | |
| Write-Host -Object "Documents changed, committing as `"$commitMsg`"" | |
| git commit -a -m $commitMsg | |
| if ($Global:LASTEXITCODE) | |
| { | |
| throw "The committing of destination repo changes failed." | |
| } | |
| # Push it to the website. | |
| Write-Host -Object "Pushing committed changes to origin." | |
| git push origin | |
| if ($Global:LASTEXITCODE) | |
| { | |
| throw "The pushing of commits from destination repo failed." | |
| } | |
| Write-Host -Object "Successfully completed operation." | |
| } | |
| else | |
| { | |
| Write-Host -Object "Found no document changes to commit." | |
| } | |
| # Pop back to the original $PWD. | |
| Pop-Location |