[EngSys] Restrict docs release jobs to public repo only#6960
[EngSys] Restrict docs release jobs to public repo only#6960
Conversation
- Add condition to PublishDocs job to skip when running from PR repo - Add condition to PublishDocsMs job to skip when running from PR repo - Add condition to CreateDocIndex job to skip when running from PR repo - Uses ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-cpp-pr') as specified in the issue Co-authored-by: danieljurek <2158838+danieljurek@users.noreply.github.com>
This job updates docs.ms build configuration and should only run from public repo Co-authored-by: danieljurek <2158838+danieljurek@users.noreply.github.com>
These files don't need the condition as they'll never run in the -pr repo Co-authored-by: danieljurek <2158838+danieljurek@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR restricts documentation publishing jobs to run only in the public repository (Azure/azure-sdk-for-cpp) and prevents them from running in the PR repository (Azure/azure-sdk-for-cpp-pr). This ensures that documentation releases to GitHub Pages and docs.ms/learn.microsoft.com only occur from the official public repository, avoiding duplicate or unwanted publishes from the PR repository.
Changes:
- Added repository name check conditions to
PublishDocsandPublishDocsMsjobs to gate execution to the public repo only - Both jobs now include
ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-cpp-pr')in their condition clauses
| - job: PublishDocs | ||
| displayName: Publish Docs to GitHub pages | ||
| condition: and(succeeded(), ne(variables['Skip.PublishDocs'], 'true')) | ||
| condition: and(succeeded(), ne(variables['Skip.PublishDocs'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-cpp-pr')) |
There was a problem hiding this comment.
The repository name check pattern used here differs from the existing pattern on line 20 of this file. Line 20 uses not(endsWith(variables['Build.Repository.Name'], '-pr')) which is more generic, while this uses an exact match for 'Azure/azure-sdk-for-cpp-pr'.
While the PR description mentions this aligns with other Azure SDK repos, having two different patterns in the same file reduces maintainability. Consider either:
- Using the same
endsWithpattern as line 20 for consistency within this file - Documenting why the exact match is preferred for job-level conditions (if there's a specific reason)
The endsWith approach would also be more maintainable if repository names change in the future.
| condition: and(succeeded(), ne(variables['Skip.PublishDocs'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-cpp-pr')) | |
| condition: and(succeeded(), ne(variables['Skip.PublishDocs'], 'true'), not(endsWith(variables['Build.Repository.Name'], '-pr'))) |
| - job: PublishDocsMs | ||
| displayName: Docs.MS Release | ||
| condition: and(succeeded(), ne(variables['Skip.PublishDocs'], 'true')) | ||
| condition: and(succeeded(), ne(variables['Skip.PublishDocs'], 'true'), ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-cpp-pr')) |
There was a problem hiding this comment.
The repository name check pattern used here differs from the existing pattern on line 20 of this file. Line 20 uses not(endsWith(variables['Build.Repository.Name'], '-pr')) which is more generic, while this uses an exact match for 'Azure/azure-sdk-for-cpp-pr'.
While the PR description mentions this aligns with other Azure SDK repos, having two different patterns in the same file reduces maintainability. Consider either:
- Using the same
endsWithpattern as line 20 for consistency within this file - Documenting why the exact match is preferred for job-level conditions (if there's a specific reason)
The endsWith approach would also be more maintainable if repository names change in the future.
Pull Request Checklist
Description
Docs publishing jobs (github.io, docs.ms) were running from both public and PR repos. Added condition
ne(variables['Build.Repository.Name'], 'Azure/azure-sdk-for-cpp-pr')to gate execution to public repo only.Changes
eng/pipelines/templates/stages/archetype-cpp-release.yml: Added condition toPublishDocsjob (github.io publishing) andPublishDocsMsjob (docs.ms/learn.microsoft.com publishing)Condition format aligns with other Azure SDK repos for consistency.
Note: Initial changes to
eng/common/pipelines/templates/jobs/docindex.ymlandeng/pipelines/docindex.ymlwere reverted as those pipelines don't run in the -pr repo.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.