Summary
- The OSDC (k8s pod) docs build cannot upload docs previews to S3: fork PRs cannot authenticate via OIDC from the build job, and we don't want to grant the pod's IAM role S3 write access on
doc-previews/. - Move the upload out of the build pod.
build-docs-osdcnow stages the built docs as a GHA artifact (docs-preview-osdc-<docs_type>) along with apr-metadata.txtthat records the PR number. - A new
upload-docs-previewworkflow is triggered byworkflow_runon completion of thepullworkflow. It runs in the base-repo context (full OIDC + secrets), downloads the staged artifact, and performs theaws s3 synctos3://doc-previews/pytorch/pytorch/<PR#>[/cppdocs]. This works for fork PRs. - The EC2 docs upload path (which uses the EC2 instance profile credentials) is unchanged.
- The C++ docs coverage PR comment stays in
_docs.ymlbut is now gated on the PR being from a branch in the base repo, so the read-only forkGITHUB_TOKENno longer causes spurious failures. - The OSDC nightly C++ dry-run upload step is removed; if needed it can be restored later by extending the new uploader to trigger on additional workflows.
Follow-ups (out of scope here)
- Update the trust policy of
arn:aws:iam::308535385114:role/arcso it can be assumed from thisworkflow_runworkflow (the OIDC subject points to the base repo, so this should already be compatible). - Optionally drop S3 write to
doc-previews/from the OSDC pod's IAM policy now that the pod no longer uploads.
Test plan
- Open a same-repo PR after this lands; verify
docs-preview-osdc-pythonanddocs-preview-osdc-cppartifacts are produced bylinux-docs. - Verify the
Upload docs previewworkflow_run job runs to completion and uploads tos3://doc-previews/pytorch/pytorch/<PR#>/and<PR#>/cppdocs/. - Verify the preview URLs resolve:
https://docs-preview.pytorch.org/pytorch/pytorch/<PR#>/index.htmland.../<PR#>/cppdocs/index.html. - Open a fork PR (or simulate one); confirm the artifacts upload and the workflow_run uploader still publishes the preview (previously the OSDC path silently no-op'd).
- Confirm the C++ coverage comment still posts on same-repo PRs touching
docs/cpp/, and skips cleanly on fork PRs without producing a failed step.
Authored by Claude.
Pull Request resolved: #184414
Approved by: https://github.com/svekars
SOCIAL SHARE CARD GENERATOR