diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/tools/ci/website_build.sh | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/tools/ci/website_build.sh')
-rwxr-xr-x | testing/web-platform/tests/tools/ci/website_build.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/ci/website_build.sh b/testing/web-platform/tests/tools/ci/website_build.sh new file mode 100755 index 0000000000..adfdf41ae7 --- /dev/null +++ b/testing/web-platform/tests/tools/ci/website_build.sh @@ -0,0 +1,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 |