-
Notifications
You must be signed in to change notification settings - Fork 300
212 lines (207 loc) Β· 8.79 KB
/
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Build docs
on:
push:
branches: ['main']
pull_request:
jobs:
build:
runs-on: ["ubuntu-22.04"]
steps:
# Based on https://github.com/actions/runner-images/issues/2840
- name: πͺ Remove some stuff we don't need
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: π’ Install stuff we need
run: |
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: π Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
submodules: recursive
lfs: true
fetch-depth: 1
- name: Create /mnt/airflow-site directory
run: sudo mkdir -p /mnt/airflow-site
- name: Move repository to /mnt
run: |
sudo mv /home/runner/work/airflow-site/airflow-site /mnt/
# Create symbolic link
sudo mkdir -p /home/runner/work/airflow-site
sudo ln -s /mnt/airflow-site /home/runner/work/airflow-site/airflow-site
- name: Set working directory to /mnt/airflow-site
working-directory: /mnt/airflow-site
run: echo "Working directory set to /mnt/airflow-site"
- name: Display disk free
run: /mnt/airflow-site/.github/scripts/print_df.sh
working-directory: /mnt/airflow-site
- name: π Setup Python
uses: actions/setup-python@bd6b4b6205c4dbad673328db7b31b7fab9e241c0 # v4.6.1
with:
python-version: '3.7'
- name: β€οΈ Install Node 16
uses: actions/setup-node@v3.3.0 # v3.3.0
with:
node-version: 16
- name: π Install Hugo
uses: peaceiris/actions-hugo@v2.4.13 # v2.4.13
with:
hugo-version: '0.91.2'
extended: true
- name: π’ Install node dependencies
run: |
/mnt/airflow-site/site.sh install-node-deps
/mnt/airflow-site/.github/scripts/print_df.sh
- name: π Install Python dependencies
run: |
pip install -r requirements.txt
/mnt/airflow-site/.github/scripts/print_df.sh
- name: Ensure cache directory exists and adjust permissions
run: |
mkdir -p /mnt/airflow-site/.cache/pre-commit
sudo chmod -R 777 /mnt/airflow-site/.cache/pre-commit
- name: π Lint
uses: apache/airflow-pre-commit-action@0764670bf370aab253130d534e1eda7ff497dc60 # v2.0.0
env:
PRE_COMMIT_HOME: /mnt/airflow-site/.cache/pre-commit
- name: π Checkout gh-pages branch with minimum depth
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # 3.5.3
if: ${{ github.event_name == 'push' }}
with:
ref: gh-pages
fetch-depth: 1
path: dist
- name: π§ Build site
run: |
/mnt/airflow-site/site.sh build-site
/mnt/airflow-site/.github/scripts/print_df.sh
- run: |
rm -rf ./docs-archive/*
echo "docs-archive directory files are deleted as they are no longer needed after the site is built in the above step"
/mnt/airflow-site/.github/scripts/print_df.sh
- name: π
Optimize artifacts
if: ${{ github.event_name == 'pull_request' }}
run: |
rm -rf ./dist/docs/*
echo "These files have been deleted to optimize the size of the artifacts." > ./dist/docs/index.html
echo "Here was the contents of the ./docs-archive directory" >> ./dist/docs/index.html
find ./dist/
/mnt/airflow-site/.github/scripts/print_df.sh
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
name: π Upload website as artifact
if: ${{ github.event_name == 'pull_request' }}
with:
name: airflow-website
path: './dist'
if-no-files-found: error
retention-days: 14
- name: π· Copy .asf.yaml to /dist/
if: ${{ github.event_name == 'push' }}
run: |
# The asf.yaml file must be in the branch from which the files are published.
# Otherwise, ASF publising tools cannot detect it.
cp .asf.yaml ./dist/
/mnt/airflow-site/.github/scripts/print_df.sh
- name: πͺ Remove node and node modules
run: |
rm -rf node_modules
sudo rm -rf "$AGENT_TOOLSDIRECTORY/node"
/mnt/airflow-site/.github/scripts/print_df.sh
- name: π Amend gh-pages branch and deploy it with force (replacing previous pages)
if: ${{ github.event_name == 'push' }}
working-directory: dist
run: |
../.github/scripts/print_df.sh
echo "Running git config"
git config user.name "GitHub Actions"
git config user.email "actions@users.noreply.github.com"
echo "Running git add"
git add .
../.github/scripts/print_df.sh
echo "Running git commit"
git commit --amend --no-edit > ../git_commit.log
../.github/scripts/print_df.sh
git push --force origin gh-pages
../.github/scripts/print_df.sh
- name: π Upload git commit log as artifacts
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: airflow-git-commit-log
path: './git_commit.log'
retention-days: 5
- name: π§ Copy files from site to theme
run: |
./site.sh prepare-theme
./.github/scripts/print_df.sh
- name: π§ Prepare sphinx_airflow_theme package οΈ
working-directory: sphinx_airflow_theme
run: |
python3 -m pip install --user --upgrade setuptools wheel
python3 setup.py sdist bdist_wheel
../.github/scripts/print_df.sh
- name: π Upload sphinx_airflow_theme package as artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: airflow-sphinx-theme
path: './sphinx_airflow_theme/dist'
if-no-files-found: error
retention-days: 14
- name: π§ Build theme demo
working-directory: sphinx_airflow_theme
run: |
pip install ./dist/sphinx_airflow_theme-*.whl
cd demo
./docs.sh build
../../.github/scripts/print_df.sh
- name: π Upload sphinx_airflow_theme demo as artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: airflow-sphinx-theme-demo
path: './sphinx_airflow_theme/demo/_build'
if-no-files-found: error
retention-days: 14
- name: π Create releases on GitHub
working-directory: sphinx_airflow_theme
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_COMMIT: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
if: >
github.ref == 'refs/heads/main' && github.repository == 'apache/airflow-site' &&
github.event_name == 'push'
run: |
set -x
gh auth status
VERSION="$(python setup.py --version 2>/dev/null | tail -1)"
TITLE=$(date "+%Y-%m-%d %H:%M:%S")
NOTES="Commit: ${GITHUB_COMMIT}
Source: ${GITHUB_REF}"
gh release delete "${VERSION}" -y || true
gh release create "${VERSION}" \
--title "${TITLE}" \
--notes "${NOTES}" \
./dist/*
../.github/scripts/print_df.sh