Skip to content

Bump github/codeql-action from 2.13.4 to 3.25.5 (#812) #159

Bump github/codeql-action from 2.13.4 to 3.25.5 (#812)

Bump github/codeql-action from 2.13.4 to 3.25.5 (#812) #159

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@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
token: ${{ steps.generate-application-token.outputs.token }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0
- name: Update documentation
id: update-docs
shell: pwsh
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 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')
});