From 0197af1697d9ab0a4e6d55aeefc231db7586de41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3jcik?= Date: Sat, 18 May 2024 21:43:45 +0200 Subject: [PATCH] Adds new pipline to prepare release --- .github/workflows/prepare-release.yml | 41 ++++++++++++++++++++++++ scripts/createScriptSampleDefenition.ps1 | 22 ++++++------- 2 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/prepare-release.yml diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..4075b92 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,41 @@ +name: "[Prototype] Prepare Release" + +on: + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' + - name: Checkout PnP PowerShell VS Code Extension + uses: actions/checkout@v4 + with: + path: pnp-powershell-extension + - name: Checkout PnP PowerShell + uses: actions/checkout@v4 + with: + repository: pnp/powershell + path: powershell + - name: Checkout PnP Script Samples + uses: actions/checkout@v4 + with: + repository: pnp/script-samples + path: script-samples + - name: Run create script samples script + run: .\pnp-powershell-extension\scripts\createScriptSampleDefenition.ps1 -PathToWorkspace ".\" + shell: pwsh + continue-on-error: false + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + path: pnp-powershell-extension + commit-message: prepare release + branch: prepare-release + title: Prepare Release + body: Prepare Release +... \ No newline at end of file diff --git a/scripts/createScriptSampleDefenition.ps1 b/scripts/createScriptSampleDefenition.ps1 index 4b7c560..8cc1b59 100644 --- a/scripts/createScriptSampleDefenition.ps1 +++ b/scripts/createScriptSampleDefenition.ps1 @@ -1,11 +1,9 @@ -param ($scriptSampleFolderPath) +param ( + [Parameter(Mandatory = $true)] + [string]$PathToWorkspace +) -if ($null -eq $scriptSampleFolderPath -or $scriptSampleFolderPath -eq "") { - write-host "Please pass path to script samples from pnp/script-sample repo" - exit -} - -$allSamples = Get-ChildItem -Path "$scriptSampleFolderPath\scripts\**\sample.json" -Recurse -Force +$allSamples = Get-ChildItem -Path "$PathToWorkspace\script-samples\scripts\**\sample.json" -Recurse -Force [hashtable]$sampleModel = @{} $samples = @() @@ -31,10 +29,10 @@ foreach ($sample in $allSamples) { $rawUrl = $rawUrl.Replace('.html', '.md') $sampleAuthors = @() - foreach($author in $sampleJson.authors) { + foreach ($author in $sampleJson.authors) { $sampleAuthors += [pscustomobject]@{ - name = $author.name; - pictureUrl = $author.pictureUrl; + name = $author.name; + pictureUrl = $author.pictureUrl; } } @@ -53,7 +51,9 @@ foreach ($sample in $allSamples) { $sampleModel.Add('samples', $samples) $orderedSampleModel = [ordered]@{} + foreach ($Item in ($sampleModel.GetEnumerator() | Sort-Object -Property Key)) { $orderedSampleModel[$Item.Key] = $Item.Value } -New-Object -TypeName psobject -Property $orderedSampleModel | ConvertTo-Json -Depth 10 | Out-File "..\data\samples.json" + +New-Object -TypeName psobject -Property $orderedSampleModel | ConvertTo-Json -Depth 10 | Out-File "$PathToWorkspace\pnp-powershell-extension\data\samples.json"