Skip to content

Commit 6ceeac4

Browse files
committed
Update doc-build.yml
1 parent ab62707 commit 6ceeac4

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

.github/workflows/doc-build.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,29 @@ jobs:
9999
REF_TYPE=${{ github.ref_type }}
100100
REF_NAME=${{ github.ref_name }}
101101
102+
# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
103+
REF_NAME=$(echo "${{ github.ref }}")
104+
echo "Ref name: ${REF_NAME}"
105+
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
106+
find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
107+
fi
108+
102109
# If building for a release tag, branch, set the branch/tag name
103110
# as the target folder in the gh-pages branch. The artifacts created
104111
# during the build will be copied over to the target dir in the
105112
# gh-pages branch.
106113
if [[ "${REF_TYPE}" == branch ]]; then
107114
TARGET_FOLDER="${REF_NAME}"
108115
elif [[ "${REF_TYPE}" == tag ]]; then
109-
# Strip the leading "v" as well as the trailing patch version and "-rc" suffix.
110-
# For example: 'v0.1.2' -> '0.1' and 'v0.1.2-rc1' -> 0.1.
111-
TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/^v//i; s/-rc[0-9]*$//; s/\.[0-9]*$//')
112-
else
113-
echo "ERROR: Invalid REF_TYPE: ${REF_TYPE}. Expected 'branch' or 'tag'."
114-
exit 1
116+
case "${REF_NAME}" in
117+
*-rc*)
118+
echo "Aborting upload since this is an RC tag: ${REF_NAME}"
119+
exit 0
120+
;;
121+
*)
122+
TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/')
123+
;;
124+
esac
115125
fi
116126
echo "Target Folder: ${TARGET_FOLDER}"
117127
@@ -122,12 +132,6 @@ jobs:
122132
mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}"
123133
git add "${TARGET_FOLDER}" || true
124134
125-
# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
126-
if [[ "${REF_NAME}" == 'main' ]]; then
127-
find "${TARGET_FOLDER}" -type f -name "*.html" -exec sed -i '/<head>/a <meta name="robots" content="noindex">' {} \;
128-
git add "${TARGET_FOLDER}"/**/*.html || true
129-
fi
130-
131135
git config user.name 'pytorchbot'
132136
git config user.email '[email protected]'
133137
git commit -m "Auto-generating sphinx docs" || true

0 commit comments

Comments
 (0)