Skip to content

Update permissions reference file #20

Update permissions reference file

Update permissions reference file #20

name: Update permissions reference file
on:
schedule:
- cron: 0 6 * * 1 # Runs every Monday at 6 AM UTC
workflow_dispatch: # Allows manual triggering of the workflow
permissions:
contents: write
pull-requests: write
jobs:
update-permissions-reference:
name: Update permissions reference
runs-on: windows-latest
steps:
- name: Set up Git to handle long paths
run: git config --system core.longpaths true
- name: Checkout microsoft-graph-docs
uses: actions/[email protected]
with:
path: docs
- name: Run PowerShell script to update permissions
shell: pwsh
run: |
$ClientId = "${{ secrets.GRAPH_CLIENT_ID }}"
$TenantId = "${{ secrets.GRAPH_TENANT_ID }}"
$ClientSecret = "${{ secrets.GRAPH_CLIENT_SECRET }}"
./docs/update-permissions-reference.ps1 -ClientId $ClientId -TenantId $TenantId -ClientSecret $ClientSecret
- name: Get token
id: get_token
uses: microsoftgraph/[email protected]
with:
application-id: ${{ secrets.APPLICATION_ID }}
application-private-key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
- name: Commit updates from service principal
working-directory: ./docs
shell: pwsh
env:
GH_TOKEN: ${{ steps.get_token.outputs.app-token }}
run: |
$status = git status --porcelain
if ($status -eq $null) {
Write-Host "No changes to commit." -ForegroundColor Green
}
else {
git config user.email "[email protected]"
git config user.name "Microsoft Graph DevX Tooling"
git add .
git commit -m "Update permissions reference"
}
- name: Run PowerShell script to correct errors in permissions descriptions
shell: pwsh
run: |
./docs/correct-permissions-reference-errors.ps1
- name: Commit errors correction and open a pull request
working-directory: ./docs
shell: pwsh
env:
GH_TOKEN: ${{ steps.get_token.outputs.app-token }}
run: |
$status = git status --porcelain
if ($status -eq $null) {
Write-Host "No changes to commit." -ForegroundColor Green
} else {
$dateToday = Get-Date -Format 'yyyy-MM-dd'
$branchName = "permissions-reference/$dateToday"
$prTitle = "${dateToday}: Automated permissions reference update"
git add .
git commit -m "Correct errors in permissions reference"
git checkout -b $branchName
git push --set-upstream origin $branchName -f
gh pr create --base main --title $prTitle --body "Scheduled permissions reference update" --reviewer "FaithOmbongi,msewaweru" --label "ready for content review"
}