Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
fixup! [docs] Build w/GH Actions and deploy w/GH Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Apr 29, 2019
1 parent 9a0807b commit 35ebe2e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 23 deletions.
6 changes: 0 additions & 6 deletions .github/main.workflow
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ workflow "Build & Publish Documentation Website" {
resolves = ["website-build-and-publish"]
}

action "master branch only" {
uses = "actions/bin/filter@master"
args = "branch master"
}

action "website-build-and-publish" {
uses = "./tools/docker/documentation"
runs = ["/bin/bash", "tools/ci/website_build.sh"]
secrets = ["DEPLOY_TOKEN"]
needs = ["master branch only"]
}
59 changes: 42 additions & 17 deletions tools/ci/website_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,46 @@ set -x

neutral_status=78
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/web-platform-tests/wpt-actions-test.git

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'
}

function modifies_relevant_files {
base_revision=$(
cat ${GITHUB_EVENT_PATH} | \
python -c 'import json, sys; print json.load(sys.stdin)["before"]'
)
base_revision=$(json_property ${GITHUB_EVENT_PATH} before)

git diff --name-only ${base_revision} | \
grep -E --silent '^(docs|tools)/'
}

if is_pull_request ; then
echo Submission comes from a pull request. Exiting without building.

exit ${neutral_status}
fi

if ! targets_master ; then
echo Submission does not target the 'master' branch. Exiting without building.

exit ${neutral_status}
fi

if ! modifies_relevant_files ; then
echo No files related to the website have been modified. Exiting without
echo building.
Expand All @@ -35,6 +64,12 @@ cd _build/html

git init

git fetch --depth 1 ${remote_url}

git checkout FETCH_HEAD

git rm -r .

# Configure DNS
echo web-platform-tests.org > CNAME

Expand All @@ -44,18 +79,8 @@ touch .nojekyll

git add .

cat <<HERE |
Build documentation
git commit --message "Build documentation
These files were generated from commit ${source_revision}
HERE
git commit --file -
These files were generated from commit ${source_revision}"

# 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
git push --force \
https://${DEPLOY_TOKEN}@github.com/web-platform-tests/wpt-actions-test.git master:gh-pages
git push --force ${remote_url} HEAD:gh-pages

0 comments on commit 35ebe2e

Please sign in to comment.