Skip to content

Commit

Permalink
Deploying on heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
ssurabhi10 committed Jul 31, 2017
2 parents ba182a3 + f1c43c9 commit 2e9c753
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@ services:
- mongodb
cache:
directories:
- node_modules
- node_modules
git:
depth: 3
install:
- git clone $GIT_CLONE_REMOTE
- cd $REPO_NAME
- git checkout $TRAVIS_BRANCH
- npm i
script: npm run travis-script
after_script:
- npm report-coverage
before_script:
- npm install -g gulp-cli
before_deploy:
- if [ "$TRAVIS_BRANCH" == "develop" ] ; then if [ "$TRAVIS_PULL_REQUEST" == "false"] ; then bash travis.sh ; fi ; fi
deploy:
app: $APP_NAME
app: $PROVIDER_APP_NAME
provider: $PROVIDER
on:
repo: surabhi226005/express-mongoose-es6-rest-api
branch: release
repo: $PROVIDER_REPO_NAME
all_branches: true
api_key:
secure: $TRAVIS_SECURE_API_KEY
after_success:
- if [ "$TRAVIS_BRANCH" == "develop" ] ; then
if [ "$TRAVIS_PULL_REQUEST" == "false" ] ; then bash travis.sh ; fi ; fi
9 changes: 3 additions & 6 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ const envVarsSchema = Joi.object({
}),
JWT_SECRET: Joi.string().required()
.description('JWT Secret required to sign'),
MONGO_HOST: Joi.string().required()
.description('Mongo DB host url'),
MONGO_PORT: Joi.number()
.default(27017)
MONGODB_URI: Joi.string().required()
.description('Mongo DB host url')
}).unknown()
.required();

Expand All @@ -36,8 +34,7 @@ const config = {
mongooseDebug: envVars.MONGOOSE_DEBUG,
jwtSecret: envVars.JWT_SECRET,
mongo: {
host: envVars.MONGO_HOST,
port: envVars.MONGO_PORT
host: envVars.MONGODB_URI
}
};

Expand Down
28 changes: 15 additions & 13 deletions travis.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
# vi /etc/ssh/ssh_config
# i Host 192.168.0.* StrictHostKeyChecking no UserKnownHostsFile=/dev/null

# cd ~/.ssh
# rm known_hosts
# ln -s /dev/null known_hosts

git config --global user.name "$GIT_USER_NAME"

git config --global user.email $GIT_USER_EMAIL

# Install the Heroku gem (or the Heroku toolbelt)
gem install $PROVIDER

# Add your Heroku git repo:
git remote rm $PROVIDER ;
git remote rm $PROVIDER ;

git remote add $PROVIDER git@$PROVIDER.com:$PROVIDER_APP_NAME.git ;

# Add your Heroku API key:
export HEROKU_API_KEY=$HEROKU_API_KEY

# Turn off warnings about SSH keys:
echo " Host heroku.com" >> ~/.ssh/config

echo " StrictHostKeyChecking no" >> ~/.ssh/config

echo " CheckHostIP no" >> ~/.ssh/config

echo " UserKnownHostsFile=/dev/null" >> ~/.ssh/config

# Clear your current Heroku SSH keys:
$PROVIDER keys:clear

# Add a new SSH key to Heroku
yes | $PROVIDER keys:add

git add dist/ ;

git checkout -b $NEW_TRAVIS_BRANCH ;
git commit -m "$TRAVIS_COMMIT_MESSAGE" ;
# Push to Heroku!
git fetch --all --unshallow
yes | git push --force $PROVIDER $NEW_TRAVIS_BRANCH:$PROVIDER_BRANCH ;

git commit -m "$TRAVIS_COMMIT_MESSAGE" ;

# echo -e "yes" | ./travis.sh
# Push to Heroku
yes | git push --force $PROVIDER $NEW_TRAVIS_BRANCH:$PROVIDER_BRANCH ;

0 comments on commit 2e9c753

Please sign in to comment.