Skip to content

Commit 68c199f

Browse files
authored
Merge pull request #917 from pnp/copilot/automate-cmdlet-help-update
Automate cmdlet help updates via Git clone and monthly workflow
2 parents 5454c10 + 51aaa68 commit 68c199f

File tree

10 files changed

+1883
-1696
lines changed

10 files changed

+1883
-1696
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Update Cmdlet Help
2+
on:
3+
schedule:
4+
# Run monthly on the 1st day at 00:00 UTC
5+
- cron: '0 0 1 * *'
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
update-help:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Clone help repositories
20+
run: |
21+
mkdir -p docfx/help-repos
22+
cd docfx/help-repos
23+
24+
# Clone PnP PowerShell documentation
25+
git clone --depth 1 https://github.com/pnp/powershell.git pnp-powershell
26+
27+
# Clone CLI for Microsoft 365 documentation
28+
git clone --depth 1 https://github.com/pnp/cli-microsoft365.git cli-microsoft365
29+
30+
# Clone SharePoint PowerShell documentation
31+
git clone --depth 1 https://github.com/MicrosoftDocs/OfficeDocs-SharePoint-PowerShell.git OfficeDocs-SharePoint-PowerShell
32+
33+
- name: Run Get-HelpJson.ps1
34+
shell: pwsh
35+
run: |
36+
cd docfx
37+
./Get-HelpJson.ps1
38+
39+
- name: Check for changes
40+
id: check_changes
41+
run: |
42+
if git diff --quiet docfx/assets/help/*.help.json; then
43+
echo "has_changes=false" >> $GITHUB_OUTPUT
44+
else
45+
echo "has_changes=true" >> $GITHUB_OUTPUT
46+
fi
47+
48+
- name: Create Pull Request
49+
if: steps.check_changes.outputs.has_changes == 'true'
50+
uses: peter-evans/create-pull-request@v6
51+
with:
52+
token: ${{ secrets.GITHUB_TOKEN }}
53+
commit-message: 'Update cmdlet help documentation'
54+
title: 'Update Cmdlet Help Documentation'
55+
body: |
56+
## Automated Cmdlet Help Update
57+
58+
This PR updates the cmdlet help documentation by pulling the latest changes from the upstream repositories:
59+
- [pnp/powershell](https://github.com/pnp/powershell)
60+
- [pnp/cli-microsoft365](https://github.com/pnp/cli-microsoft365)
61+
- [MicrosoftDocs/OfficeDocs-SharePoint-PowerShell](https://github.com/MicrosoftDocs/OfficeDocs-SharePoint-PowerShell)
62+
63+
The following help files have been updated:
64+
- `docfx/assets/help/powershell.help.json` - PnP PowerShell cmdlets
65+
- `docfx/assets/help/cli.help.json` - CLI for Microsoft 365 commands
66+
- `docfx/assets/help/spoms.help.json` - SharePoint Online Management Shell cmdlets
67+
68+
Please review the changes and merge if everything looks correct.
69+
branch: automated/update-cmdlet-help
70+
delete-branch: true
71+
labels: |
72+
automated
73+
documentation

docfx/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/**/bin/
88
/**/obj/
99
_site
10+
help-repos/

docfx/Get-HelpJson.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ function Process-CliForM365Docs
119119
# For optimatization - only use help where cmdlet is used
120120

121121
# To refresh functions use . .\Get-HelpJson.ps1 in cmd window
122-
$currentLocation = "C:\git\readonly\script-samples-help\"
123-
$outputPath = "$(Get-Location)\assets\help"
122+
# Get the script directory and calculate paths relative to it
123+
$scriptPath = if ($PSScriptRoot) { $PSScriptRoot } else { Get-Location }
124+
$currentLocation = Join-Path -Path $scriptPath -ChildPath "help-repos"
125+
$outputPath = Join-Path -Path $scriptPath -ChildPath "assets\help"
126+
127+
# Ensure output directory exists
128+
if (!(Test-Path -Path $outputPath)) {
129+
New-Item -ItemType Directory -Path $outputPath -Force | Out-Null
130+
}
124131

125132
Process-PnPPowerShellDocs
126133
Process-SPOManagementShellDocs

0 commit comments

Comments
 (0)