Skip to content

Bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#1007) #343

Bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#1007)

Bump ossf/scorecard-action from 2.4.0 to 2.4.1 (#1007) #343

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@d17e3a9a36850ea89f35db16c1067dd2b68ee343 # v4.0.1
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:
filter: 'tree:0'
show-progress: false
token: ${{ steps.generate-application-token.outputs.token }}
- name: Setup .NET SDK
uses: actions/setup-dotnet@3951f0dfe7a07e2313ec93c75700083e2005cbab # v4.3.0
- name: Update documentation
id: update-docs
shell: pwsh
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
UPDATER_COMMIT_USER_EMAIL: ${{ vars.UPDATER_COMMIT_USER_EMAIL }}
UPDATER_COMMIT_USER_NAME: ${{ vars.UPDATER_COMMIT_USER_NAME }}
run: |
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
dotnet tool restore
dotnet mdsnippets ${env:GITHUB_WORKSPACE} --exclude-directories ./artifacts
if ($LASTEXITCODE -ne 0) {
Write-Output "Failed to update documentation."
exit 1
}
$gitStatus = (git status --porcelain)
if ([string]::IsNullOrEmpty($gitStatus)) {
Write-Output "No changes to commit."
exit 0
}
$branchName = "update-docs/${env:GITHUB_SHA}"
git config user.email ${env:UPDATER_COMMIT_USER_EMAIL} | Out-Null
git config user.name ${env:UPDATER_COMMIT_USER_NAME} | Out-Null
git remote set-url "${env:GITHUB_SERVER_URL}/${env: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-Output "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')
});