Skip to content
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

Update doc-build.yml #3045

Closed
wants to merge 6 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions .github/workflows/doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,9 @@ jobs:

ls -R "${RUNNER_ARTIFACT_DIR}"/*/*.html

# Enable preview later. Previews are available publicly
#
# upload-preview:
# if: github.repository == 'pytorch/executorch' && github.event_name == 'push' &&
# (github.ref_type == 'branch' && github.ref_name == 'main')
# uses: pytorch/test-infra/.github/workflows/linux_job.yml@main

upload-gh-pages:
needs: build
if: github.repository == 'pytorch/executorch' && github.event_name == 'push' &&
((github.ref_type == 'branch' && github.ref_name == 'main') || github.ref_type == 'tag')
if: github.repository == 'pytorch/executorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/v'))
permissions:
contents: write
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
Expand All @@ -99,19 +91,29 @@ jobs:
REF_TYPE=${{ github.ref_type }}
REF_NAME=${{ github.ref_name }}

# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
REF_NAME=$(echo "${{ github.ref }}")
echo "Ref name: ${REF_NAME}"
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
fi

# If building for a release tag, branch, set the branch/tag name
# as the target folder in the gh-pages branch. The artifacts created
# during the build will be copied over to the target dir in the
# gh-pages branch.
if [[ "${REF_TYPE}" == branch ]]; then
TARGET_FOLDER="${REF_NAME}"
elif [[ "${REF_TYPE}" == tag ]]; then
# Strip the leading "v" as well as the trailing patch version and "-rc" suffix.
# For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1.
TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/^v//i; s/-rc[0-9]*$//; s/\.[0-9]*$//')
else
echo "ERROR: Invalid REF_TYPE: ${REF_TYPE}. Expected 'branch' or 'tag'."
exit 1
case "${REF_NAME}" in
*-rc*)
echo "Aborting upload since this is an RC tag: ${REF_NAME}"
Copy link
Contributor

@dbort dbort Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining why it makes sense to abort when encountering an RC tag. Is it because we only want to generate docs for the actual release tag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I believe this is what we do across other repositories - no documentation will be generated for v1.0.0-rc1 or similar.

exit 0
;;
*)
TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/')
svekars marked this conversation as resolved.
Show resolved Hide resolved
;;
esac
fi
echo "Target Folder: ${TARGET_FOLDER}"

Expand All @@ -122,12 +124,6 @@ jobs:
mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}"
git add "${TARGET_FOLDER}" || true

# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
if [[ "${REF_NAME}" == 'main' ]]; then
find "${TARGET_FOLDER}" -type f -name "*.html" -exec sed -i '/<head>/a <meta name="robots" content="noindex">' {} \;
git add "${TARGET_FOLDER}"/**/*.html || true
fi

git config user.name 'pytorchbot'
git config user.email 'soumith+bot@pytorch.org'
git commit -m "Auto-generating sphinx docs" || true
Expand Down
Loading