Skip to content

Commit f32361a

Browse files
committed
set up an auto-pub bot
1 parent 43c5a65 commit f32361a

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

.travis.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
sudo: false
2+
language: python
3+
python:
4+
- '2.7'
5+
install:
6+
- pip install pygments lxml setuptools --upgrade
7+
- git clone https://github.com/tabatkins/bikeshed.git
8+
- pip install --editable $PWD/bikeshed
9+
- bikeshed update
10+
script:
11+
- bash "./deploy.sh"
12+
env:
13+
global:
14+
- ENCRYPTION_LABEL: "4571b087bd76"
15+
- COMMIT_AUTHOR_EMAIL: "[email protected]"

compile.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
bikeshed spec
5+
6+
if [ -d out ]; then
7+
echo Copy the generated spec into out/index.html
8+
cp index.html out/index.html
9+
fi

deploy.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
set -e # Exit with nonzero exit code if anything fails
3+
4+
# From https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
5+
6+
SOURCE_BRANCH="master"
7+
TARGET_BRANCH="gh-pages"
8+
9+
function doCompile {
10+
chmod 755 ./compile.sh
11+
./compile.sh
12+
}
13+
14+
# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
15+
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
16+
echo "Skipping deploy; just doing a build."
17+
doCompile
18+
exit 0
19+
fi
20+
21+
# Save some useful information
22+
REPO=`git config remote.origin.url`
23+
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
24+
SHA=`git rev-parse --verify HEAD`
25+
26+
# Clone the existing gh-pages for this repo into out/
27+
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
28+
git clone $REPO out
29+
cd out
30+
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
31+
cd ..
32+
33+
# Clean out existing contents
34+
rm -rf out/**/* || exit 0
35+
36+
# Run our compile script
37+
doCompile
38+
39+
# Now let's go have some fun with the cloned repo
40+
cd out
41+
git config user.name "Travis CI"
42+
git config user.email "$COMMIT_AUTHOR_EMAIL"
43+
44+
# If there are no changes to the compiled out (e.g. this is a README update) then just bail.
45+
if git diff --quiet; then
46+
echo "No changes to the output on this push; exiting."
47+
exit 0
48+
fi
49+
50+
# Commit the "changes", i.e. the new version.
51+
# The delta will show diffs between new and old versions.
52+
git add -A .
53+
git commit -m "Deploy to GitHub Pages: ${SHA}"
54+
55+
# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
56+
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
57+
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
58+
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
59+
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
60+
openssl aes-256-cbc -K $encrypted_4571b087bd76_key -iv $encrypted_4571b087bd76_iv -in ../deploy_key.enc -out ../deploy_key -d
61+
chmod 600 ../deploy_key
62+
eval `ssh-agent -s`
63+
ssh-add ../deploy_key
64+
65+
# Now that we're all set up, we can push.
66+
git push $SSH_REPO $TARGET_BRANCH

deploy_key.enc

3.17 KB
Binary file not shown.

0 commit comments

Comments
 (0)