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 e993aa8 commit 94494f4
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 56 deletions.
43 changes: 20 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,33 @@ sudo: required
dist: trusty
language: node_js
node_js:
- stable
- stable
branches:
except:
- gh-pages
- gh-pages
addons:
firefox: latest
apt:
sources:
- google-chrome
- google-chrome
packages:
- google-chrome-stable
- google-chrome-stable
before_script:
- npm install web-component-tester
- npm install bower
- 'export PATH=$PWD/node_modules/.bin:$PATH'
- bower install
- npm install web-component-tester
- npm install bower
- export PATH=$PWD/node_modules/.bin:$PATH
- bower install
script:
- xvfb-run wct --skip-plugin sauce
- >-
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct --plugin sauce
--skip-plugin local; fi
- xvfb-run wct --skip-plugin sauce
- if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct --plugin sauce --skip-plugin
local; fi
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"
env:
global:
- secure: BzcksPX0+i9NFBsKUzO711fIWzm1DkVA+eu6smEdlTdGJCjwo33h34laz2PHZcLNedcaZfkNdQxUlkHI1m0iSrulXXqQ6cTi7EbxEzTFPjYg101BHJyNEzdh+Y6AbW+T0drRwPiJ7ej1XwllOYJCPLMMUE3DmcAKoc4vq0W/snKgLqO5t9aWhQGLtoAbppu/hfI5JLazSmt6jOWvis9nhMG/gwHBvkAS3LQPKCZ7VA80dsvtsBAQ1znJUJRrB95VyAmPim8rK0tQzk3+x1cl64bOLN7+9wj4sJP/99IPnEWEsfPowqzvs7dRvcY7BFAYx8wjgD++qgxv/A9cf6o/gsnw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p6OkX96AqiKyxZQ4BagxGbGeNI+uXoheJPT5sYxpcN1ftoI9+7FrqrZscVK2J6t6W7o/+AUBUCKPihC7ydmz+csE/bHxF78PbYGZV5DfrX1fNsAOY5akDo88TkIHa/Ry8stDarqQplw8yGYP2NobLI1A9T1wcPtS9tberCoOrYgrBIIUib9TteuGqe5asuaC4Qy4fahN6Elp2R+zTIUbGuCyMZUYMNf9RO9uhlhf813pap9hD4xLKliMLJMl/68EpgyEaRTWojmXcIt4Xabw9E0moTI+cuRxyBq7RZVkpv0u7lPbm6L2XYaRGF7KOsFT23PDIKdObWuUsOd9thiTkC3DBxH4VFTrrJcjRBBrjQYwsnlXsBsXV4YnoghImaAwImyxCHqNGGOqlVgPoMA6g8unPtmVtQuCUJMmzY8XpArTYTTFQcph1tR1MnPOdc5skVDxmZdE8g4k8IgU4/gz98Cb630NmLb55PbviSz4A94VrucZ+OGpLR/YsoIZBPB+5oCciZcr3haumiSvcyvz8m6JRL2BQQmlmNNzaSoKVUT2owDHdsrU5LpcpiqVtzwsVqqv+gEse/AtSe6CvpKotS/hKPDsIB+uzWRph0QBDRC8A0u7dUBONLSc0Tg=
before_install:
- >-
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then openssl aes-256-cbc -k
"$password" -in id_rsa.enc -out deploy_key -d; fi
after_success:
- cd $TRAVIS_BUILD_DIR/scripts
- chmod 755 ghp.sh
- ./ghp.sh
- secure: o0hBm6ktX7ISMhHOcH9Po5YPZzL2teuwleNkU/jNl2fcZ38k75bQ6KhijG1be5IwBJiOYQIOAE9B6q7ZKdnzlGRO/L2xFYiBAdr8hjarilWkSaN9htIMama3xg79VLEvoACmy16gkojtlcJ0EiGhUFdn6KuwTOG2E9BYq/ESQ4Uiaj4DhbUUAZvNdMZk/2UQn3f2+Gg9PAhb0brCiq8inTBy6t4ZnyIPNSB4D7EOfD454Ldkoh1vGRvvakYewlcPNzBLNYNi6sLsbhVKkaRCweZCNsTf2RpN/XkTWqNCR0R1GFMu/jm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deploy.enc
Binary file not shown.
Binary file removed id_rsa.enc
Binary file not shown.
118 changes: 85 additions & 33 deletions scripts/ghp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +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="PredixtravisCI@ge.com"
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 "PredixtravisCI@ge.com"

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

#remove the old .bowerrc, and replace it with one that tells bower to install everything in THIS folder, and not bower_components
rm .bowerrc
# 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

# @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

#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 --strip-comments
vulcanize demo.html -o demo.vulcanized.html --inline-scripts --inline-css --strip-comments
yes | cp index.vulcanized.html index.html
yes | cp demo.vulcanized.html demo.html
rm demo.vulcanized.html
cd ../ #remember to exit out of the component before you do any git stuff

#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: "git@github.com:PredixDev/px-something"
# Next, replace `PredixDev` Github organization with `predix-ui` so configure
# the correct remote to push to.
# The resulting URL will be: "git@github.com: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 94494f4

Please sign in to comment.