Skip to content

Commit bd1a2e3

Browse files
authored
Skip the doc preview upload on fork PRs (pytorch#22943)
A fork PR reds "Build doc" after the docs have already built successfully: Upload documentation to S3 (if any) ##[error]Credentials could not be loaded, please check your action inputs: Could not load credentials from any providers linux_job_v3 uploads whatever is left in RUNNER_DOCS_DIR to the doc-previews bucket, gated only on there being a pull request number. That upload authenticates through OIDC, which a fork PR does not have, so it can never succeed. The preview was never going to publish; the only effect is that the docs build reports as broken. Clears the directory on a fork PR so v3 skips the step. The docs still build and still upload to RUNNER_ARTIFACT_DIR, so the PR is validated exactly as before, and same-repo PRs and pushes are untouched. The general fix belongs in linux_job_v3, whose condition should require the pull request to come from the same repository rather than merely to exist. That would fix this for every repo on v3 instead of one. Authored with Claude Code.
1 parent 3447ba9 commit bd1a2e3

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎.github/workflows/doc-build.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ jobs:
9797
9898
ls -R "${RUNNER_ARTIFACT_DIR}"/*/*.html
9999
100+
# linux_job_v3 uploads whatever is left in RUNNER_DOCS_DIR to the
101+
# doc-previews bucket on every pull request, and that upload
102+
# authenticates through OIDC. A fork PR has no OIDC token, so the step
103+
# fails with "Could not load credentials from any providers" and reds
104+
# the job after the docs have already built. Clear the directory so v3
105+
# skips the upload -- a fork preview was never going to publish anyway.
106+
if [[ -n "${{ github.event.pull_request.number }}" && \
107+
"${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
108+
echo "Fork PR: skipping the doc preview upload"
109+
rm -rf "${RUNNER_DOCS_DIR:?}"/*
110+
fi
111+
100112
upload-gh-pages:
101113
needs: build
102114
if: github.repository == 'pytorch/executorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))

0 commit comments

Comments
 (0)