Skip to content

Commit

Permalink
Add new Travis deploy credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrleonard committed Dec 21, 2016
1 parent 92ea5e0 commit dae04ae
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 38 deletions.
24 changes: 16 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ language: node_js
node_js:
- stable
branches:
only:
- master
except:
- gh-pages
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
before_script:
- npm install bower
- export PATH=$PWD/node_modules/.bin:$PATH
- bower install
script:
- echo "This design module has no tests"
after_success:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then openssl aes-256-cbc -k "$DEPLOYSECRET"
-in deploy.enc -out deploy_key -d; fi
- cd $TRAVIS_BUILD_DIR/scripts
- chmod 755 ghp.sh
- ./ghp.sh
before_install:
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then openssl aes-256-cbc -k "$password"
-in id_rsa.enc -out deploy_key -d; fi
- "./ghp.sh"
env:
global:
- secure: Oukdgmte7nIRKrkJUDae23EyUjcT/l9A/3i7AS0OBRMNAAgTyxU7sO95S6QmqB8RkUbouqM3hZzHywmkXo7tPq9E5Ub25SZVD/PnsMGfnlv42naSXyiHnoT1DeRI8oVN2ufKysik5MIMCiUmniykUYy+XP7uz7fQEqXwIZ1rIc1J1UiX2+VDD0Eb6w01qnABwOZuDVTLgevLJQB143Mezc9ItFItpO0l76ImbpwnWZVmJd9tNxwOTip5W+uGHxo64ibaXEzoO0ck0Pev0LJrpzk84LBAKkHxASFuqf4euaB23hPDlEwjKoJhgXQj2SyHCT0VjxWQ8/GxQK9pZyKbbXP1Q/FlHNPEjRMNnfRBbsvbul0GANy7Cb2znEFDbbusuo27RloXzalXzsI0tloDz4n7Tfpg4vZbugY50dNloSC3I/odCndkPFkIBsdOuL/4wbaKxl2VzDHUxd2KtqBzXbwkaHBadzGrjt9scqnUnSV3l3tkgPOo/SQ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+XrHDuLFFcCc4Yx5gy7I6AA8xBxQ0Gu8wpJNki2VVItUnSPua+b8N2ZsT8ub/4pNb447e0Q=
Binary file added deploy.enc
Binary file not shown.
Binary file removed id_rsa.enc
Binary file not shown.
115 changes: 85 additions & 30 deletions scripts/ghp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,118 @@
# Exit with nonzero exit code if anything fails
set -e

# ------------------------------------------------------------------------------
# CONFIGURE SCRIPT
# ------------------------------------------------------------------------------

#set our source and traget branches
# Set our source branch (where we'll build from) and our target branch (where we
# want to send the build page to)
SOURCE_BRANCH="master"
TARGET_BRANCH="gh-pages"
REPO=`git config remote.origin.url`

#pull requests and commits to other branches shouldn't try to deploy
# Prep git credentials
GIT_USER_NAME="Travis CI"
GIT_USER_EMAIL="[email protected]"
GIT_COMMIT_MESSAGE="[Travis] Rebuild documentation for Github Pages"

# Check if we should run a deploy, or if we should skip it. Only commits to master
# should trigger a build. Pull requests and commits to features branches should not.
if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
echo "Skipping deploy; just doing a build."
exit 0
fi

#create a temp directory that will store the bower.json file
# ------------------------------------------------------------------------------
# PREPARE FILESYSTEM
# ------------------------------------------------------------------------------

# Create a temp directory that will store the bower.json file
mkdir tmp_bower

#clone this repo, and go into that folder.
# Clone this repo, and go into that folder
git clone ${REPO} ghp_tmp
cd ghp_tmp

#find out our repo name from the bower file
# Find out our repo name from the bower file
REPO_NAME=$(grep "name" bower.json | sed 's/"name": "//' | sed 's/",//')
echo "repo name is ${REPO_NAME}"

#set up our variables and configs
git config user.name "Travis CI"
git config user.email "[email protected]"

SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}

#copy the bower.json file out of the directory to a temp one
# Copy the bower.json file out of the directory to a temp one
cp bower.json ../tmp_bower/bower.json
#and checkout gh-pages - create it if it doesn't exist.
# ... and checkout gh-pages - create it if it doesn't exist.
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
# ... and copy the bower.json file from our temp directory into the current one, overriding it, and passing a yes in there's a prompt
yes | cp ../tmp_bower/bower.json bower.json

#pull to ensure this is the latest one.
git pull origin gh-pages
# Overwrite whatever is in root .bowerrc to force installation of bower packages at the root
rm -f .bowerrc
echo "{ \"directory\": \".\" }" > .bowerrc

#copy the bower.json file from our temp directory into the current one, overriding it, and passing a yes in there's a prompt
yes | cp ../tmp_bower/bower.json bower.json
# Overwrite whatever is in root `index.html` to create the redirect
# Note: We are not overwriting the component's documentation `index.html` file
# here, we are making sure that http://url/px-something/ redirects to
# http://url/px-something/px-something/, where the demo page is installed
rm -f index.html
meta_temp='<META http-equiv=refresh content="0;URL=COMPONENT_NAME/">'
echo ${meta_temp/'COMPONENT_NAME'/$REPO_NAME} > index.html

#install your new tag through bower, it will fail without forcing it.
# Install your new tag through bower (use --force because it will fail without forcing it)
bower install ${REPO_NAME} --force
# @DARK_THEME: Force install px-dark-theme (to generate dark-theme demos)
bower install px-dark-theme --force

# ------------------------------------------------------------------------------
# BUILD PROJECT
# ------------------------------------------------------------------------------

# Go into the component folder we've just installed from bower
cd ${REPO_NAME}

# @DARK_THEME: Copy `index.html` to new file, where we will add dark theme
yes | cp index.html index-dark.html

#optimize for production
cd ${REPO_NAME} #go into the component folder
npm install vulcanize -g
vulcanize index.html -o index.vulcanized.html --inline-scripts --inline-css
yes | cp index.vulcanized.html index.html
rm index.vulcanized.html
cd ../ #remember to exit out of the component before you do any git stuff
# @DARK_THEME: Import dark-theme on the `index-dark.html` page
perl -pi -w -e 's/px-theme\/px-theme-styles.html/px-dark-theme\/px-dark-theme-styles.html/g;' index-dark.html

#do the git stuff
# ------------------------------------------------------------------------------
# SW-PRECACHE
# ------------------------------------------------------------------------------

# npm install sw-precache
# sw-precache --root='.' --static-file-globs='**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff}'

# ------------------------------------------------------------------------------
# GIT PUSH TO REMOTES
# ------------------------------------------------------------------------------

# Remember to exit out of the component before we do any git stuff
cd ../

# Do the git stuff
git add .
git commit -m "rebuild github pages"
git commit -m "${GIT_COMMIT_MESSAGE}"

# Set git credentials (defined in settings above)
git config user.name ${GIT_USER_NAME}
git config user.email ${GIT_USER_EMAIL}

# We get the URL in this format: "https://github.com/PredixDev/px-something"
# First, we need to replace https-style remote URL with a SSH-style remote
# URL we can push to below
SSH_GIT=${REPO/https:\/\/github.com\//git@github.com:}

# Now, the URL is in this format: "[email protected]:PredixDev/px-something"
# Next, replace `PredixDev` Github organization with `predix-ui` so configure
# the correct remote to push to.
# The resulting URL will be: "[email protected]:predix-ui/px-something"
SSH_GIT_PREDIXUI=${SSH_GIT/:PredixDev\//:predix-ui\/}

# Prepare ssh key, which we'll use to authenticate for SSH-push deploy
eval `ssh-agent -s`
#and cahnge permissions
# ... and change permissions for deploy key
chmod 0400 $TRAVIS_BUILD_DIR/deploy_key

# Push to predix-ui/repo `gh-pages` branch (force to override out-of-date refs)
ssh-add $TRAVIS_BUILD_DIR/deploy_key
#Now that we're all set up, we can push.
git push $SSH_REPO $TARGET_BRANCH
git push $SSH_GIT_PREDIXUI $TARGET_BRANCH --force

0 comments on commit dae04ae

Please sign in to comment.