|
86 | 86 | echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV |
87 | 87 |
|
88 | 88 | - name: Check out repo |
89 | | - uses: actions/checkout@v3 |
| 89 | + uses: actions/checkout@v6 |
90 | 90 |
|
91 | 91 | - name: Remove src/ folder |
92 | 92 | run: bash packaging/remove_src.sh |
@@ -151,7 +151,7 @@ jobs: |
151 | 151 | echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV |
152 | 152 |
|
153 | 153 | - name: Check out repo |
154 | | - uses: actions/checkout@v3 |
| 154 | + uses: actions/checkout@v6 |
155 | 155 |
|
156 | 156 | - name: Remove src/ folder |
157 | 157 | run: bash packaging/remove_src.sh |
@@ -199,3 +199,81 @@ jobs: |
199 | 199 | with: |
200 | 200 | name: Built-Docs |
201 | 201 | path: docs/build/html/ |
| 202 | + |
| 203 | + doc-preview: |
| 204 | + runs-on: [self-hosted, linux.2xlarge] |
| 205 | + needs: build-docs |
| 206 | + if: github.repository == 'meta-pytorch/torchcodec' && github.event_name == 'pull_request' |
| 207 | + steps: |
| 208 | + - uses: actions/download-artifact@v4 |
| 209 | + with: |
| 210 | + name: Built-Docs |
| 211 | + path: docs |
| 212 | + |
| 213 | + # Update HTML to add the no-index tag so that search engines do not index these ephemeral docs |
| 214 | + - name: Add no-index tag |
| 215 | + run: | |
| 216 | + find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">'; |
| 217 | +
|
| 218 | + - name: Upload docs preview |
| 219 | + uses: seemethere/upload-artifact-s3@v5 |
| 220 | + with: |
| 221 | + retention-days: 14 |
| 222 | + s3-bucket: doc-previews |
| 223 | + if-no-files-found: error |
| 224 | + path: docs |
| 225 | + s3-prefix: meta-pytorch/torchcodec/${{ github.event.pull_request.number }} |
| 226 | + |
| 227 | + upload-docs: |
| 228 | + # This job uploads built docs: |
| 229 | + # - to the `main` folder of the gh-pages branch (https://meta-pytorch.org/torchcodec/main) on every commit to the `main` branch |
| 230 | + # - to the (e.g.) `0.10` folder in the gh-pages branch whenever a corresponding tag is pushed, like `v0.10.0` (https://meta-pytorch.org/torchcodec/0.10). |
| 231 | + |
| 232 | + needs: build-docs |
| 233 | + if: github.repository == 'meta-pytorch/torchcodec' && github.event_name == 'push' && |
| 234 | + ((github.ref_type == 'branch' && github.ref_name == 'main') || github.ref_type == 'tag') |
| 235 | + runs-on: ubuntu-latest |
| 236 | + steps: |
| 237 | + - name: Check out gh-pages branch |
| 238 | + uses: actions/checkout@v6 |
| 239 | + with: |
| 240 | + ref: gh-pages |
| 241 | + |
| 242 | + - uses: actions/download-artifact@v4 |
| 243 | + with: |
| 244 | + name: Built-Docs |
| 245 | + path: docs-artifact/ |
| 246 | + |
| 247 | + - name: Update docs and push |
| 248 | + run: | |
| 249 | + set -euo pipefail |
| 250 | +
|
| 251 | + REF_TYPE=${{ github.ref_type }} |
| 252 | + REF_NAME=${{ github.ref_name }} |
| 253 | +
|
| 254 | + if [[ "${REF_TYPE}" == branch ]]; then |
| 255 | + TARGET_FOLDER="${REF_NAME}" |
| 256 | + elif [[ "${REF_TYPE}" == tag ]]; then |
| 257 | + case "${REF_NAME}" in |
| 258 | + *-rc*) |
| 259 | + echo "Aborting upload since this is an RC tag: ${REF_NAME}" |
| 260 | + exit 0 |
| 261 | + ;; |
| 262 | + *) |
| 263 | + # Strip the leading "v" as well as the trailing patch version. For example: |
| 264 | + # 'v0.10.2' -> '0.10' |
| 265 | + TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/') |
| 266 | + ;; |
| 267 | + esac |
| 268 | + fi |
| 269 | + echo "Target Folder: ${TARGET_FOLDER}" |
| 270 | +
|
| 271 | + mkdir -p "${TARGET_FOLDER}" |
| 272 | + rm -rf "${TARGET_FOLDER}"/* |
| 273 | + cp -r docs-artifact/* "${TARGET_FOLDER}/" |
| 274 | + git add "${TARGET_FOLDER}" |
| 275 | +
|
| 276 | + git config user.name 'pytorchbot' |
| 277 | + git config user.email 'soumith+bot@pytorch.org' |
| 278 | + git commit -m "auto-generating sphinx docs for ${TARGET_FOLDER}" || echo "No changes to commit" |
| 279 | + git push |
0 commit comments