|
1 | | -name: update-documentation |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - branches: [ master ] |
6 | | - paths: [ '**/*.md', 'test/WebSites/DocumentationSnippets/**' ] |
7 | | - workflow_dispatch: |
8 | | - |
9 | | -permissions: {} |
10 | | - |
11 | | -jobs: |
12 | | - update-docs: |
13 | | - name: update-docs |
14 | | - runs-on: ubuntu-latest |
15 | | - if: github.event.repository.fork == false |
16 | | - |
17 | | - permissions: |
18 | | - contents: write |
19 | | - pull-requests: write |
20 | | - |
21 | | - steps: |
22 | | - |
23 | | - - name: Checkout code |
24 | | - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
25 | | - with: |
26 | | - filter: 'tree:0' |
27 | | - persist-credentials: true # zizmor: ignore[artipacked] Needed to push commits |
28 | | - show-progress: false |
29 | | - |
30 | | - - name: Setup .NET SDK |
31 | | - uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 |
32 | | - |
33 | | - - name: Update documentation |
34 | | - id: update-docs |
35 | | - shell: pwsh |
36 | | - env: |
37 | | - DOTNET_CLI_TELEMETRY_OPTOUT: true |
38 | | - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
39 | | - GIT_COMMIT_USER_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com' |
40 | | - GIT_COMMIT_USER_NAME: 'github-actions[bot]' |
41 | | - run: | |
42 | | - $ErrorActionPreference = "Stop" |
43 | | - $ProgressPreference = "SilentlyContinue" |
44 | | -
|
45 | | - dotnet tool restore |
46 | | - dotnet mdsnippets |
47 | | -
|
48 | | - $GitStatus = (git status --porcelain) |
49 | | - if ([string]::IsNullOrEmpty($GitStatus)) { |
50 | | - Write-Output "No changes to commit." |
51 | | - exit 0 |
52 | | - } |
53 | | -
|
54 | | - $BranchName = "docs/update-docs" |
55 | | - "branchName=$BranchName" >> ${env:GITHUB_OUTPUT} |
56 | | -
|
57 | | - git config user.email ${env:GIT_COMMIT_USER_EMAIL} | Out-Null |
58 | | - git config user.name ${env:GIT_COMMIT_USER_NAME} | Out-Null |
59 | | - git remote set-url "${env:GITHUB_SERVER_URL}/${env:GITHUB_REPOSITORY}.git" | Out-Null |
60 | | - git fetch origin | Out-Null |
61 | | - git rev-parse --verify --quiet ("remotes/origin/" + $BranchName) | Out-Null |
62 | | -
|
63 | | - if ($LASTEXITCODE -eq 0) { |
64 | | - Write-Output "Branch $BranchName already exists." |
65 | | - exit 0 |
66 | | - } |
67 | | -
|
68 | | - git checkout -b $BranchName |
69 | | - git add . |
70 | | - git commit -m "Update the code-snippets in the documentation" -s |
71 | | - git push -u origin $BranchName |
72 | | - "updated-docs=true" >> ${env:GITHUB_OUTPUT} |
73 | | -
|
74 | | - - name: Create pull request |
75 | | - if: steps.update-docs.outputs.updated-docs == 'true' |
76 | | - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
77 | | - env: |
78 | | - BASE_BRANCH_NAME: ${{ github.event.repository.default_branch }} |
79 | | - HEAD_BRANCH_NAME: ${{ steps.update-docs.outputs.branchName }} |
80 | | - with: |
81 | | - script: | |
82 | | - const { repo, owner } = context.repo; |
83 | | - const workflowUrl = `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID}`; |
84 | | - const { data: pr } = await github.rest.pulls.create({ |
85 | | - title: 'Update the code-snippets in the documentation', |
86 | | - owner, |
87 | | - repo, |
88 | | - head: process.env.HEAD_BRANCH_NAME, |
89 | | - base: process.env.BASE_BRANCH_NAME, |
90 | | - body: [ |
91 | | - 'This PR updates the code-snippets in the documentation.', |
92 | | - '', |
93 | | - `This pull request was generated by [GitHub Actions](${workflowUrl}).` |
94 | | - ].join('\n') |
95 | | - }); |
96 | | - core.notice(`Created pull request ${owner}/${repo}#${pr.number}: ${pr.html_url}`); |
| 1 | +name: update-documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + paths: [ '**/*.md', 'test/WebSites/DocumentationSnippets/**' ] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: {} |
| 10 | + |
| 11 | +jobs: |
| 12 | + update-docs: |
| 13 | + name: update-docs |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: github.event.repository.fork == false |
| 16 | + |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + pull-requests: write |
| 20 | + |
| 21 | + steps: |
| 22 | + |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 25 | + with: |
| 26 | + filter: 'tree:0' |
| 27 | + persist-credentials: true # zizmor: ignore[artipacked] Needed to push commits |
| 28 | + show-progress: false |
| 29 | + |
| 30 | + - name: Setup .NET SDK |
| 31 | + uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 |
| 32 | + |
| 33 | + - name: Update documentation |
| 34 | + id: update-docs |
| 35 | + shell: pwsh |
| 36 | + env: |
| 37 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 38 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 39 | + GIT_COMMIT_USER_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com' |
| 40 | + GIT_COMMIT_USER_NAME: 'github-actions[bot]' |
| 41 | + run: | |
| 42 | + $ErrorActionPreference = "Stop" |
| 43 | + $ProgressPreference = "SilentlyContinue" |
| 44 | +
|
| 45 | + dotnet tool restore |
| 46 | + dotnet mdsnippets |
| 47 | +
|
| 48 | + $GitStatus = (git status --porcelain) |
| 49 | + if ([string]::IsNullOrEmpty($GitStatus)) { |
| 50 | + Write-Output "No changes to commit." |
| 51 | + exit 0 |
| 52 | + } |
| 53 | +
|
| 54 | + $BranchName = "docs/update-docs" |
| 55 | + "branchName=$BranchName" >> ${env:GITHUB_OUTPUT} |
| 56 | +
|
| 57 | + git config user.email ${env:GIT_COMMIT_USER_EMAIL} | Out-Null |
| 58 | + git config user.name ${env:GIT_COMMIT_USER_NAME} | Out-Null |
| 59 | + git remote set-url "${env:GITHUB_SERVER_URL}/${env:GITHUB_REPOSITORY}.git" | Out-Null |
| 60 | + git fetch origin | Out-Null |
| 61 | + git rev-parse --verify --quiet ("remotes/origin/" + $BranchName) | Out-Null |
| 62 | +
|
| 63 | + if ($LASTEXITCODE -eq 0) { |
| 64 | + Write-Output "Branch $BranchName already exists." |
| 65 | + exit 0 |
| 66 | + } |
| 67 | +
|
| 68 | + git checkout -b $BranchName |
| 69 | + git add . |
| 70 | + git commit -m "Update the code-snippets in the documentation" -s |
| 71 | + git push -u origin $BranchName |
| 72 | + "updated-docs=true" >> ${env:GITHUB_OUTPUT} |
| 73 | +
|
| 74 | + - name: Create pull request |
| 75 | + if: steps.update-docs.outputs.updated-docs == 'true' |
| 76 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 77 | + env: |
| 78 | + BASE_BRANCH_NAME: ${{ github.event.repository.default_branch }} |
| 79 | + HEAD_BRANCH_NAME: ${{ steps.update-docs.outputs.branchName }} |
| 80 | + with: |
| 81 | + script: | |
| 82 | + const { repo, owner } = context.repo; |
| 83 | + const workflowUrl = `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID}`; |
| 84 | + const { data: pr } = await github.rest.pulls.create({ |
| 85 | + title: 'Update the code-snippets in the documentation', |
| 86 | + owner, |
| 87 | + repo, |
| 88 | + head: process.env.HEAD_BRANCH_NAME, |
| 89 | + base: process.env.BASE_BRANCH_NAME, |
| 90 | + body: [ |
| 91 | + 'This PR updates the code-snippets in the documentation.', |
| 92 | + '', |
| 93 | + `This pull request was generated by [GitHub Actions](${workflowUrl}).` |
| 94 | + ].join('\n') |
| 95 | + }); |
| 96 | + core.notice(`Created pull request ${owner}/${repo}#${pr.number}: ${pr.html_url}`); |
0 commit comments