1#!/bin/bash 2# =================== The following code **should** be executed inside Docker container =================== 3 4# Install dependencies 5sudo apt-get -y update 6sudo apt-get -y install expect-dev 7 8# This is where the local pytorch install in the docker image is located 9pt_checkout="/var/lib/jenkins/workspace" 10source "$pt_checkout/.ci/pytorch/common_utils.sh" 11echo "functorch_doc_push_script.sh: Invoked with $*" 12 13set -ex 14 15version=${DOCS_VERSION:-nightly} 16echo "version: $version" 17 18# Build functorch docs 19pushd $pt_checkout/functorch/docs 20pip -q install -r requirements.txt 21make html 22popd 23 24git clone https://github.com/pytorch/functorch -b gh-pages --depth 1 functorch_ghpages 25pushd functorch_ghpages 26 27if [ $version == "main" ]; then 28 version=nightly 29fi 30 31git rm -rf "$version" || true 32mv "$pt_checkout/functorch/docs/build/html" "$version" 33 34git add "$version" || true 35git status 36git config user.email "soumith+bot@pytorch.org" 37git config user.name "pytorchbot" 38# If there aren't changes, don't make a commit; push is no-op 39git commit -m "Generate Python docs from pytorch/pytorch@${GITHUB_SHA}" || true 40git status 41 42if [[ "${WITH_PUSH:-}" == true ]]; then 43 git push -u origin gh-pages 44fi 45 46popd 47# =================== The above code **should** be executed inside Docker container =================== 48