Unverified Commit 19b2d3ca authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

reinstate doc upload (#7580)

parent 99ec261c
......@@ -7,6 +7,9 @@ on:
- nightly
- main
- release/*
tags:
- v[0-9]+.[0-9]+.[0-9]
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:
jobs:
......@@ -14,6 +17,7 @@ jobs:
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
repository: pytorch/vision
upload-artifact: docs
script: |
set -euo pipefail
......@@ -44,4 +48,60 @@ jobs:
sed -i -e 's/-j auto/-j 1/' Makefile
make html
mv build/html/* "${RUNNER_DOCS_DIR}"
cp -r build/html "${RUNNER_ARTIFACT_DIR}"
# On PRs we also want to upload the docs into our S3 bucket for preview.
if [[ ${{ github.event_name == 'pull_request' }} ]]; then
cp -r build/html/* "${RUNNER_DOCS_DIR}"
fi
upload:
needs: build
if: github.repository == 'pytorch/vision' && github.event_name == 'push' &&
((github.ref_type == 'branch' && github.ref_name == 'main') || github.ref_type == 'tag')
permissions:
contents: write
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
repository: pytorch/vision
download-artifact: docs
ref: gh-pages
script: |
set -euo pipefail
REF_TYPE=${{ github.ref_type }}
REF_NAME=${{ github.ref_name }}
if [[ "${REF_TYPE}" == branch ]]; then
TARGET_FOLDER="${REF_NAME}"
elif [[ "${REF_TYPE}" == tag ]]; then
case "${REF_NAME}" in
*-rc*)
echo "Aborting upload since this is an RC tag: ${REF_NAME}"
exit 0
;;
*)
# Strip the leading "v" as well as the trailing patch version. For example:
# 'v0.15.2' -> '0.15'
TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/')
;;
esac
fi
echo "Target Folder: ${TARGET_FOLDER}"
mkdir -p "${TARGET_FOLDER}"
rm -rf "${TARGET_FOLDER}"/*
mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}"
git add "${TARGET_FOLDER}" || true
if [[ "${TARGET_FOLDER}" == main ]]; then
mkdir -p _static
rm -rf _static/*
cp -r "${TARGET_FOLDER}"/_static/* _static
git add _static || true
fi
git config user.name 'pytorchbot'
git config user.email 'soumith+bot@pytorch.org'
git commit -m "auto-generating sphinx docs" || true
git push
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment