-
-
Save siriniok/4076202a116da2878592 to your computer and use it in GitHub Desktop.
Simple Codeship CI, testing and deployment scripts for Rails with Ember CLI frontend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
init() { | |
# Use ruby version specified in .ruby-version file | |
rvm use $(cat .ruby-version) | |
# Use Postgress 9.3 version on Codeship (port 5433) | |
sed -i "s|5432|5433|" "config/database.yml" | |
# Install gem dependencies | |
bundle install | |
# Init frontend | |
cd frontend | |
# Install node version | |
nvm use 0.12.7 | |
# Install npm dependencies | |
npm install | |
# Install bower dependencies | |
bower install | |
cd .. | |
} | |
tests() { | |
source tests | |
} | |
deploy() { | |
source deploy --stage | |
source deploy --beta | |
source deploy --production | |
} | |
print_help () { | |
echo "Usage: sorce ci --(init|test|deploy)" | |
} | |
if [ $# -eq 0 ]; then | |
print_help | |
fi | |
for i in "$@" | |
do | |
case $i in | |
-i|--init) | |
init | |
shift | |
;; | |
-t|--tests) | |
tests | |
shift | |
;; | |
-d|--deploy) | |
deploy | |
shift | |
;; | |
-h|--help) | |
print_help | |
shift | |
;; | |
*) | |
echo "Unknown option" | |
;; | |
esac | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
stage() { | |
cap staging deploy | |
} | |
beta() { | |
cap beta deploy | |
} | |
production() { | |
cap production deploy | |
} | |
print_help () { | |
echo "Usage: source deploy (-t|--target)=(stage|beta|production)" | |
} | |
if [ $# -eq 0 ]; then | |
print_help | |
fi | |
for i in "$@" | |
do | |
case $i in | |
-t=stage|--target=stage) | |
stage | |
shift | |
;; | |
-t=beta|--target=beta) | |
beta | |
shift | |
;; | |
-t=production|--target=production) | |
production | |
shift | |
;; | |
# Example of general usage: | |
# -t=*|--target=*) | |
# TARGET="${i#*=}" | |
# shift | |
# ;; | |
-h|--help) | |
print_help | |
shift | |
;; | |
*) | |
echo "Unknown option" | |
;; | |
esac | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export RAILS_ENV=test | |
# Run Rails tests | |
bundle exec rake test | |
# Run Ember tests | |
cd frontend/ | |
ember test | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source ci --help
source ci --init
source ci --tests
source ci --deploy