@@ -99,19 +99,29 @@ jobs:
99
99
REF_TYPE=${{ github.ref_type }}
100
100
REF_NAME=${{ github.ref_name }}
101
101
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
+
102
109
# If building for a release tag, branch, set the branch/tag name
103
110
# as the target folder in the gh-pages branch. The artifacts created
104
111
# during the build will be copied over to the target dir in the
105
112
# gh-pages branch.
106
113
if [[ "${REF_TYPE}" == branch ]]; then
107
114
TARGET_FOLDER="${REF_NAME}"
108
115
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
115
125
fi
116
126
echo "Target Folder: ${TARGET_FOLDER}"
117
127
@@ -122,12 +132,6 @@ jobs:
122
132
mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}"
123
133
git add "${TARGET_FOLDER}" || true
124
134
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
-
131
135
git config user.name 'pytorchbot'
132
136
git config user.email '[email protected] '
133
137
git commit -m "Auto-generating sphinx docs" || true
0 commit comments