Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Finish setting up deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Mar 15, 2016
1 parent 6131230 commit 365dcdf
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
/out/

npm-debug.log
deploy_key
3 changes: 1 addition & 2 deletions .travis.yml
@@ -1,8 +1,7 @@
script: bash ./deploy.sh
env:
global:
- GH_REF: github.com/domenic/zones.git
- secure: TODO
- ENCRYPTION_LABEL: 5ebd09854806
language: node_js
node_js:
- stable
35 changes: 28 additions & 7 deletions deploy.sh
@@ -1,18 +1,27 @@
#!/bin/bash
set -e # Exit with nonzero exit code if anything fails

# Pull requests and non-master commits shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "master" ]; then
echo "Skipping deploy for a pull request; just doing a build"
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"

# Pull requests and commits to other branches shouldn't try to deploy, just build to verify
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
echo "Skipping deploy; just doing a build."
npm run spec
exit 0
fi

# Save the current commit's hash
# 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`

# Clone the existing gh-pages for this repo into out/
git clone -b gh-pages "https://${GH_REF}" out
# Create a new empty branch if gh-pages doesn't exist yet (should only happen on first deply)
git clone $REPO out
cd out
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
cd ..

# Clean out existing contents
rm -rf out/**/* || exit 0
Expand All @@ -25,8 +34,20 @@ cd out
git config user.name "Travis CI"
git config user.email "d@domenic.me"

# Commit and push the "changes", i.e. the new version.
# Commit the "changes", i.e. the new version.
# The delta will show diffs between new and old versions.
git add .
git commit -m "Deploy to GitHub Pages: ${SHA}"
git push "https://${GH_TOKEN}@${GH_REF}" gh-pages

# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc
ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key"
ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv"
ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR}
ENCRYPTED_IV=${!ENCRYPTED_IV_VAR}
openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy_key.enc -out deploy_key -d
chmod 600 deploy_key
eval `ssh-agent -s`
ssh-add deploy_key

# 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.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -15,5 +15,8 @@
"spec"
],
"author": "Domenic Denicola <d@domenic.me> (https://domenic.me/)",
"license": "CC0-1.0"
"license": "CC0-1.0",
"devDependencies": {
"ecmarkup": "^3.1.1"
}
}
2 changes: 0 additions & 2 deletions spec.html
@@ -1,5 +1,3 @@
<!DOCTYPE html>
<meta charset="utf-8">
<pre class="metadata">
title: Zones
status: proposal
Expand Down

0 comments on commit 365dcdf

Please sign in to comment.