blob: adfdf41ae73812de177978ac07f87d6c8eb10b10 (
plain)
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
|
#!/bin/bash
set -ex
neutral_status=0
source_revision=$(git rev-parse HEAD)
# The token available in the `GITHUB_TOKEN` variable may be used to push to the
# repository, but GitHub Pages will not rebuild the website in response to such
# events. Use an access token generated for the project's machine user,
# wpt-pr-bot.
#
# https://help.github.com/en/articles/generic-jekyll-build-failures
remote_url=https://${DEPLOY_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
wpt_root=$PWD
function json_property {
cat ${1} | \
python -c "import json, sys; print(json.load(sys.stdin).get(\"${2}\", \"\"))"
}
function is_pull_request {
test -n "$(json_property ${GITHUB_EVENT_PATH} pull_request)"
}
function targets_master {
test $(json_property ${GITHUB_EVENT_PATH} ref) == 'refs/heads/master'
}
git config --global user.email "wpt-pr-bot@users.noreply.github.com"
git config --global user.name "wpt-pr-bot"
# Prepare the output directory so that the new build can be pushed to the
# repository as an incremental change to the prior build.
mkdir -p docs/_build
cd docs/_build
git init
git fetch --depth 1 ${remote_url} gh-pages
git checkout FETCH_HEAD
git rm -rf .
# Build the website
unset NODE_ENV
cd ${wpt_root}/docs
npm install .
export PATH="$PWD/node_modules/.bin:$PATH"
cd ${wpt_root}
./wpt build-docs
cd docs/_build
# Configure DNS
echo web-platform-tests.org > CNAME
# Disable Jekyll
# https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/
touch .nojekyll
# Publish the website by pushing the built contents to the `gh-pages` branch
git add .
echo This submission alters the compiled files as follows
git diff --staged
if is_pull_request ; then
echo Submission comes from a pull request. Exiting without publishing.
exit ${neutral_status}
fi
if ! targets_master ; then
echo Submission does not target the 'master' branch. Exiting without publishing.
exit ${neutral_status}
fi
if git diff --exit-code --quiet --staged ; then
echo No change to the website contents. Exiting without publishing.
exit ${neutral_status}
fi
git commit --message "Build documentation
These files were generated from commit ${source_revision}"
git push --force ${remote_url} HEAD:gh-pages
|