Skip to content

Bump ReportGenerator from 5.3.9 to 5.3.10 (#899) #238

Bump ReportGenerator from 5.3.9 to 5.3.10 (#899)

Bump ReportGenerator from 5.3.9 to 5.3.10 (#899) #238

Workflow file for this run

name: update-docs
on:
push:
branches: [ main ]
paths-ignore:
- '**/*.md'
workflow_dispatch:
permissions: {}
jobs:
update-docs:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}
steps:
- name: Generate GitHub application token
id: generate-application-token
uses: peter-murray/workflow-application-token-action@dc0413987a085fa17d19df9e47d4677cf81ffef3 # v3.0.0
with:
application_id: ${{ secrets.UPDATER_APPLICATION_ID }}
application_private_key: ${{ secrets.UPDATER_APPLICATION_PRIVATE_KEY }}
permissions: "contents:write, pull_requests:write"
- name: Checkout code
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
with:
token: ${{ steps.generate-application-token.outputs.token }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1
- name: Update documentation
id: update-docs
shell: pwsh
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
run: |
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
dotnet tool restore
dotnet mdsnippets "$env:GITHUB_WORKSPACE" --exclude-directories ./artifacts
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to update documentation."
exit 1
}
$gitStatus = (git status --porcelain)
if ([string]::IsNullOrEmpty($gitStatus)) {
Write-Host "No changes to commit."
exit 0
}
$branchName = "update-docs/$($env:GITHUB_SHA)"
git config user.email "${{ vars.UPDATER_COMMIT_USER_EMAIL }}" | Out-Null
git config user.name "${{ vars.UPDATER_COMMIT_USER_NAME }}" | Out-Null
git remote set-url "${{ github.server_url }}/${{ github.repository }}.git" | Out-Null
git fetch origin | Out-Null
git rev-parse --verify --quiet "remotes/origin/$branchName" | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Host "Branch $branchName already exists."
exit 0
}
git checkout -b $BranchName
git add .
git commit -m "Update documentation`n`nUpdate examples in documentation." -s
git push -u origin $branchName
"branchName=$branchName" >> $env:GITHUB_OUTPUT
"updated-docs=true" >> $env:GITHUB_OUTPUT
- name: Create pull request
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: steps.update-docs.outputs.updated-docs == 'true'
env:
BRANCH_NAME: ${{ steps.update-docs.outputs.branchName }}
with:
github-token: ${{ steps.generate-application-token.outputs.token }}
script: |
const { repo, owner } = context.repo;
const workflowUrl = `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID}`;
await github.rest.pulls.create({
title: 'Update documentation',
owner,
repo,
head: process.env.BRANCH_NAME,
base: 'main',
body: [
'Update examples in documentation.',
'',
`This pull request was generated by [GitHub Actions](${workflowUrl}).`
].join('\n')
});