74
74
75
75
ls -R "${RUNNER_ARTIFACT_DIR}"/*/*.html
76
76
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
-
84
77
upload-gh-pages :
85
78
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'))
88
80
permissions :
89
81
contents : write
90
82
uses : pytorch/test-infra/.github/workflows/linux_job.yml@main
99
91
REF_TYPE=${{ github.ref_type }}
100
92
REF_NAME=${{ github.ref_name }}
101
93
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
+
102
101
# If building for a release tag, branch, set the branch/tag name
103
102
# as the target folder in the gh-pages branch. The artifacts created
104
103
# during the build will be copied over to the target dir in the
@@ -108,10 +107,16 @@ jobs:
108
107
elif [[ "${REF_TYPE}" == tag ]]; then
109
108
# Strip the leading "v" as well as the trailing patch version and "-rc" suffix.
110
109
# 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
115
120
fi
116
121
echo "Target Folder: ${TARGET_FOLDER}"
117
122
@@ -122,12 +127,6 @@ jobs:
122
127
mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}"
123
128
git add "${TARGET_FOLDER}" || true
124
129
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
130
git config user.name 'pytorchbot'
132
131
git config user.email '[email protected] '
133
132
git commit -m "Auto-generating sphinx docs" || true
0 commit comments