Skip to content

Commit

Permalink
Enable Travis to auto-build HTML output
Browse files Browse the repository at this point in the history
  • Loading branch information
clelland committed Jun 19, 2018
1 parent 9ed3860 commit 8945e72
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2,848 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
index.html
deploy_key
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: python
python:
- '2.7'
env:
global:
- COMMIT_AUTHOR_EMAIL=travis-ci@w3.org
install:
- git clone --depth=1 --branch=master https://github.com/tabatkins/bikeshed.git ./bikeshed
- pip install pygments
- pip install --upgrade setuptools
- pip install --editable ./bikeshed
- bikeshed update
script:
- mkdir out
- bikeshed spec index.bs out/index.html
before_deploy:
- openssl aes-256-cbc -K $encrypted_b330ad4127a4_key -iv $encrypted_b330ad4127a4_iv
-in deploy_key.enc -out deploy_key -d
deploy:
provider: script
skip_cleanup: true
script: "./deploy.sh"

This comment has been minimized.

Copy link
@foolip

foolip Jun 19, 2018

Member

FYI, I learned a few weeks ago about "provider: pages", which I used to simplify some of my similar setups to not have a deploy key. https://github.com/w3c/speech-api/blob/master/.travis.yml is an example.

on:
branch: master
47 changes: 47 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Expects that the build script will place the contents of gh-pages into out/.
# Expects that the before_deploy steps will place a deploy key in ./deploy_key.

TARGET_BRANCH=gh-pages

# Save some useful information
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD`

CLONED_TARGET_BRANCH=$(mktemp -d)
# Clone the existing gh-pages for this repo into out/
git clone --depth 1 --branch $TARGET_BRANCH $REPO $CLONED_TARGET_BRANCH

# Copy over the out/ directory, removing any old contents.
rsync -r --exclude .git --delete out/ $CLONED_TARGET_BRANCH

# Install the deploy key.
chmod 600 deploy_key
eval `ssh-agent -s`
if ! ssh-add deploy_key; then
echo "Unable to add SSH identity; exiting."
exit 1
fi

# Now let's go have some fun with the cloned repo
cd $CLONED_TARGET_BRANCH
# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
if git diff --quiet; then
echo "No changes to the output on this push; exiting."
exit 0
fi

git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"

# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add -A .
git commit -m "Deploy to GitHub Pages: ${SHA}"

# Now that we're all set up, we can push.
git push $SSH_REPO $TARGET_BRANCH

Binary file added deploy_key.enc
Binary file not shown.
Loading

0 comments on commit 8945e72

Please sign in to comment.