-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move code from markdown to snippets (#1540)
- Loading branch information
Showing
17 changed files
with
593 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: on-push-do-docs | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
paths: [ "src/Snippets/**" ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
update-docs: | ||
name: update-docs | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | ||
|
||
- name: Setup .NET SDK | ||
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.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 | ||
|
||
$GitStatus = (git status --porcelain) | ||
if ([string]::IsNullOrEmpty($GitStatus)) { | ||
Write-Host "No changes to commit." | ||
exit 0 | ||
} | ||
|
||
$TimeStamp = Get-Date -Format "yyyy-MM-dd-HH-mm" | ||
$BranchName = "docs/update-docs-$TimeStamp" | ||
"branchName=$BranchName" >> $env:GITHUB_OUTPUT | ||
|
||
$GitEmail = "138034000+polly-updater-bot[bot]@users.noreply.github.com" | ||
$GitUser = "polly-updater-bot[bot]" | ||
|
||
git config user.email $GitEmail | Out-Null | ||
git config user.name $GitUser | 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 the code-snippets in the documentation" | ||
git push -u origin $BranchName | ||
"updated-docs=true" >> $env:GITHUB_OUTPUT | ||
|
||
- name: Generate GitHub application token | ||
if: steps.update-docs.outputs.updated-docs == 'true' | ||
id: generate-application-token | ||
uses: peter-murray/workflow-application-token-action@8e1ba3bf1619726336414f1014e37f17fbadf1db # v2.1.0 | ||
with: | ||
application_id: ${{ secrets.POLLY_UPDATER_BOT_APP_ID }} | ||
application_private_key: ${{ secrets.POLLY_UPDATER_BOT_KEY }} | ||
permissions: "contents:write, pull_requests:write" | ||
|
||
- name: Create pull request | ||
if: steps.update-docs.outputs.updated-docs == 'true' | ||
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 | ||
with: | ||
github-token: ${{ steps.generate-application-token.outputs.token }} | ||
script: | | ||
const { repo, owner } = context.repo; | ||
const workflowUrl = `${{ github.server_url }}/${owner}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID}`; | ||
const branchName = "${{ steps.update-docs.outputs.branchName }}"; | ||
const result = await github.rest.pulls.create({ | ||
title: 'Update the code-snippets in the documentation', | ||
owner, | ||
repo, | ||
head: branchName, | ||
base: 'main', | ||
body: [ | ||
'This PR updates the code-snippets in the documentation.', | ||
'', | ||
`This pull request was generated by [GitHub Actions](${workflowUrl}).` | ||
].join('\n') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Benchmarks | ||
# Benchmarks | ||
|
||
To run the benchmarks, use the `benchmarks.ps1` script in this repository: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/SimonCropp/MarkdownSnippets/main/schema.json", | ||
"ExcludeDirectories": [ "test", "artifacts", "bench", "eng" ], | ||
"ExcludeSnippetDirectories": [ "src/Polly", "src/Polly.Core", "src/Polly.RateLimiting", "src/Polly.Testing", "src/Polly.Extensions", "artifacts", "test" ], | ||
"OmitSnippetLinks": true, | ||
"Convention": "InPlaceOverwrite" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.