Skip to content
Permalink
Browse files

Build: Add wet-boew-dist CI builds

Use a simplified version of the current post_build script for deploying
assets on Travis builds
  • Loading branch information...
nschonni committed Sep 13, 2013
1 parent d16da93 commit 180164619508331a97c2fbe99687a313788e5d8d
Showing with 88 additions and 8 deletions.
  1. +1 −0 .gitignore
  2. +3 −1 .travis.yml
  3. +23 −6 Gruntfile.coffee
  4. +2 −1 package.json
  5. +59 −0 travis.sh
@@ -27,3 +27,4 @@ csslint.out.xml
*.log
node_modules/
lib/
wet-boew-dist/
@@ -5,14 +5,16 @@ node_js:
env:
global:
- secure: "gwTdJcQxqg2Bxai+N9+T8tPJFnOexZRI1j2tVOHobvnMOaRVg9IU6Or+Q7Qz\nxIPtw7NlPFXhadwgRpEL0Y/I38mJlpXIAKmKAsUnEwyD4gdplbxlVXQZN54r\nGX7dzXpw94LYtRjquCeV5HpX8iMNnF4jgMbj94P1q8teWkyB7wM="
- POST_BUILD=true

before_install:
- ./run-first

script:
- npm test

after_success:
- ./travis.sh

notifications:
irc:
- "chat.freenode.net#wet-boew"
@@ -270,20 +270,36 @@ module.exports = (grunt) ->
csv: "src/i18n/i18n.csv"
src: "src/js/i18n/formvalid/*.js"

"gh-pages":
options:
repo: "https://" + process.env.GH_TOKEN + "@github.com/wet-boew/wet-boew-dist.git"
branch: "v4.0-dist"
clone: "wet-boew-dist"
message: "Travis build " + process.env.TRAVIS_BUILD_NUMBER
src: [
"dist/**/*.*",
"*.html",
"*.md",
"*.txt"
]


# These plugins provide necessary tasks.
@loadNpmTasks "assemble"
@loadNpmTasks "grunt-contrib-clean"
@loadNpmTasks "grunt-contrib-coffee"
@loadNpmTasks "grunt-contrib-concat"
@loadNpmTasks "grunt-contrib-connect"
@loadNpmTasks "grunt-contrib-copy"
@loadNpmTasks "grunt-contrib-cssmin"
@loadNpmTasks "grunt-contrib-uglify"
@loadNpmTasks "grunt-contrib-jshint"
@loadNpmTasks "grunt-contrib-uglify"
@loadNpmTasks "grunt-contrib-watch"
@loadNpmTasks "grunt-contrib-coffee"
@loadNpmTasks "grunt-contrib-clean"
@loadNpmTasks "grunt-contrib-connect"
@loadNpmTasks "grunt-sass"
@loadNpmTasks "grunt-modernizr"
@loadNpmTasks "assemble"
@loadNpmTasks "grunt-gh-pages"
@loadNpmTasks "grunt-sass"

# Load custom grunt tasks form the tasks directory
@loadTasks "tasks"

# Default task.
@@ -295,3 +311,4 @@ module.exports = (grunt) ->
@registerTask "html", ["assemble"]
@registerTask "server", ["connect", "watch:source"]
@registerTask "init", ["modernizr"]
@registerTask "deploy", ["gh-pages"]
@@ -41,6 +41,7 @@
"csv": "~0.3.6",
"grunt-modernizr": "~0.3.0",
"assemble": "~0.4.5",
"grunt-contrib-cssmin": "~0.6.1"
"grunt-contrib-cssmin": "~0.6.1",
"grunt-gh-pages": "~0.7.2"
}
}
@@ -0,0 +1,59 @@
#!/bin/bash
start=$(date +%s)
echo -e "Current repo: $TRAVIS_REPO_SLUG\n"

function error_exit
{
echo -e "\e[01;31m$1\e[00m" 1>&2
exit 1
}

if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_REPO_SLUG" == "wet-boew/wet-boew" ]; then

#Set git user
git config --global user.email "ws-nw@tbs-sct.gc.ca"
git config --global user.name "wet-boew"

#Add the latest build result
echo -e "Uploading the build artifact for branch $TRAVIS_BRANCH\n"

build_branch="$TRAVIS_BRANCH-dist"

grunt deploy 2> /dev/null || error_exit "Error cloning the artifact repository";

echo -e "Done uploading the build artifact for branch $TRAVIS_BRANCH\n"

#Update the working examples
echo -e "Updating working examples...\n"

cd ..
git clone -q https://${GH_TOKEN}@github.com/wet-boew/wet-boew.github.io.git 2> /dev/null || error_exit "Error cloning the working examples repository";
cd wet-boew.github.io

if [ "$TRAVIS_BRANCH" == "master" ]; then
submodule_name="wet-boew"
else
submodule_name="$TRAVIS_BRANCH-ci"
fi

echo -e "Updating submodule '$submodule_name'"
#Use the existing local repo for initializing the submodule
git submodule update --reference ../wet-boew-dist --init "$submodule_name"

cd "$submodule_name"
#Checkout dist branch to move forward submodule HEAD pointer
git checkout $build_branch
cd ..
git add .
git commit -q -m "Travis build $TRAVIS_BUILD_NUMBER"
git push -fq origin master 2> /dev/null || error_exit "Error uploading the working examples"

echo -e "Finished updating the working examples\n"

fi

end=$(date +%s)
elapsed=$(( $end - $start ))
minutes=$(( $elapsed / 60 ))
seconds=$(( $elapsed % 60 ))
echo "Post-Build process finished in $minutes minute(s) and $seconds seconds"

0 comments on commit 1801646

Please sign in to comment.
You can’t perform that action at this time.