7474
7575 ls -R "${RUNNER_ARTIFACT_DIR}"/*/*.html
7676
77- # Enable preview later. Previews are available publicly
78- #
79- # upload-preview:
80- # if: github.repository == 'pytorch/executorch' && github.event_name == 'push' &&
81- # (github.ref_type == 'branch' && github.ref_name == 'main')
82- # uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
83-
8477 upload-gh-pages :
8578 needs : build
86- if : github.repository == 'pytorch/executorch' && github.event_name == 'push' &&
87- ((github.ref_type == 'branch' && github.ref_name == 'main') || github.ref_type == 'tag')
79+ 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'))
8880 permissions :
8981 contents : write
9082 uses : pytorch/test-infra/.github/workflows/linux_job.yml@main
9991 REF_TYPE=${{ github.ref_type }}
10092 REF_NAME=${{ github.ref_name }}
10193
94+ # If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
95+ REF_NAME=$(echo "${{ github.ref }}")
96+ echo "Ref name: ${REF_NAME}"
97+ if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
98+ find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
99+ fi
100+
102101 # If building for a release tag, branch, set the branch/tag name
103102 # as the target folder in the gh-pages branch. The artifacts created
104103 # during the build will be copied over to the target dir in the
@@ -108,10 +107,16 @@ jobs:
108107 elif [[ "${REF_TYPE}" == tag ]]; then
109108 # Strip the leading "v" as well as the trailing patch version and "-rc" suffix.
110109 # 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
110+ case "${REF_NAME}" in
111+ *-rc*)
112+ echo "Aborting upload since this is an RC tag: ${REF_NAME}"
113+ # We don't generate -rc* documentation but for actual tag only.
114+ exit 0
115+ ;;
116+ *)
117+ TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/')
118+ ;;
119+ esac
115120 fi
116121 echo "Target Folder: ${TARGET_FOLDER}"
117122
@@ -122,12 +127,6 @@ jobs:
122127 mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}"
123128 git add "${TARGET_FOLDER}" || true
124129
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-
131130 git config user.name 'pytorchbot'
132131 git config user.email '[email protected] ' 133132 git commit -m "Auto-generating sphinx docs" || true
0 commit comments