-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Move code from markdown to snippets #1540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+593
−73
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c8da56c
Move code from markdown to snippets
martintmk 33aab72
Use InPlaceOverwrite
martintmk b3dadd9
Drop unnecessary change
martintmk 70d3899
Drop generated file note
martintmk aba5dfe
fixes
martintmk e9e2572
Update the workflow file
martintmk 2500d3c
Move snippets to src folder
martintmk 2f8a4b7
PR comments
martintmk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.