Skip to content

Bump github/codeql-action from 3.27.4 to 3.27.5 (#945) #282

Bump github/codeql-action from 3.27.4 to 3.27.5 (#945)

Bump github/codeql-action from 3.27.4 to 3.27.5 (#945) #282

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@8e4e6fbf6fcc8a272781d97597969d21b3812974 # v4.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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ steps.generate-application-token.outputs.token }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
- 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')
});