diff --git a/.github/workflows/publish-docfx.yml b/.github/workflows/publish-docfx.yml index 890f7b5d3e..f3afb493fe 100644 --- a/.github/workflows/publish-docfx.yml +++ b/.github/workflows/publish-docfx.yml @@ -7,7 +7,7 @@ on: push: branches: ["main"] paths: ["docs/**", ".github/workflows/publish-docfx.yml"] - + pull_request: branches: ["main"] paths: ["docs/**", ".github/workflows/publish-docfx.yml"] @@ -42,6 +42,12 @@ jobs: - run: chmod +x ./scripts/generate-docfx-yml.ps1 - run: ./scripts/generate-docfx-yml.ps1 ./docs shell: pwsh + - run: chmod +x ./scripts/docfx-replace-url.ps1 + shell: pwsh + - run: ./scripts/docfx-replace-url.ps1 + shell: pwsh + - run: Set-Item -Path Env:DOCFX_SOURCE_BRANCH_NAME -Value 'main' + shell: pwsh - run: docfx docfx.json - run: chmod +x ./scripts/update-docfx-site.ps1 - name: Commit Changes diff --git a/scripts/docfx-replace-url.ps1 b/scripts/docfx-replace-url.ps1 new file mode 100644 index 0000000000..5f140783cd --- /dev/null +++ b/scripts/docfx-replace-url.ps1 @@ -0,0 +1,23 @@ +# Define the custom link to replace "../src" +$customLink = "https://github.com/microsoft/msquic/tree/main/src" + +# Get the directory of markdown files from the user input +$dir = "./docs" + +# Get all the markdown files in the directory +$files = Get-ChildItem -Path $dir -Filter *.md + +# Loop through each file +foreach ($file in $files) { + # Read the file content as a string + $content = Get-Content -Path $file.FullName -Raw + + # Replace all occurrences of "../src" with the custom link + $content = $content -replace "\.\./src", $customLink + + # Write the modified content back to the file + Set-Content -Path $file.FullName -Value $content +} + +# Write a message to indicate the completion of the task +Write-Host "All done!"