-
Notifications
You must be signed in to change notification settings - Fork 354
118 lines (100 loc) · 3.86 KB
/
doc-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Build documentation
on:
pull_request:
push:
branches:
- main
- release/*
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
build:
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
strategy:
matrix:
include:
- build-tool: buck2
with:
job-name: Build doc
runner: linux.2xlarge
docker-image: executorch-ubuntu-22.04-clang12
submodules: 'true'
repository: pytorch/executorch
upload-artifact: docs
timeout: 90
script: |
# The generic Linux job chooses to use base env, not the one setup by the image
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
conda activate "${CONDA_ENV}"
BUILD_TOOL=${{ matrix.build-tool }}
# Setup dependencies as there is no Docker support
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
export CHANNEL=test
else
export CHANNEL=nightly
fi
# Get the version of ExecuTorch from REF_NAME and save as ET_VERSION_DOCS
# ET_VERSION_DOCS will be pulled during the doc build to add to the version dropdown
# on the website. See docs/source/conf.py for details
GITHUB_REF=${{ github.ref }}
echo "$GITHUB_REF"
export ET_VERSION_DOCS="${GITHUB_REF}"
echo "$ET_VERSION_DOCS"
set -eux
# clean up the ${RUNNER_DOCS_DIR} if exists:
rm -rf "${RUNNER_DOCS_DIR}"/*
# clean up the ${RUNNER_ARTIFACT_DIR} if exists:
rm -rf "${RUNNER_ARTIFACT_DIR}"/*
# Build docset:
cd docs
doxygen source/Doxyfile
make html
cd ..
# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.
echo "GitHub Ref: ${GITHUB_REF}"
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
find docs/_build/html/ -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
fi
cp -rf docs/_build/html/* "${RUNNER_DOCS_DIR}"
mv docs/_build/html "${RUNNER_ARTIFACT_DIR}"
ls -R "${RUNNER_ARTIFACT_DIR}"/*/*.html
upload-gh-pages:
needs: build
if: github.repository == 'pytorch/executorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
permissions:
contents: write
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
repository: pytorch/executorch
download-artifact: docs
ref: gh-pages
timeout: 90
script: |
set -euo pipefail
# Get github.ref for the output doc folder. By default "main"
# If matches a tag like refs/tags/v1.12.0-rc3 or
# refs/tags/v1.12.0 convert to 1.12
export GITHUB_REF=${{ github.ref }}
# Convert refs/tags/v1.12.0rc3 into 1.12.
# Adopted from https://github.com/pytorch/pytorch/blob/main/.github/workflows/_docs.yml#L150C11-L155C13
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+) ]]; then
TARGET_FOLDER="${BASH_REMATCH[1]}"
else
TARGET_FOLDER="main"
fi
echo "Target Folder: ${TARGET_FOLDER}"
mkdir -p "${TARGET_FOLDER}"
# Clean up target folder if exists and copy html output to the
# Target folder
rm -rf "${TARGET_FOLDER}"/*
mv "${RUNNER_ARTIFACT_DIR}"/html/* "${TARGET_FOLDER}"
git add "${TARGET_FOLDER}" || true
git config user.name 'pytorchbot'
git config user.email 'soumith+bot@pytorch.org'
git commit -m "Auto-generating sphinx docs" || true
git push -f