在 Travis CI 上持续将两个分支部署到两个单独的 openshift 应用程序?

Continuously deploy two branches to two separate openshift applications on Travis CI?

我有一个 git 存储库,它有许多开发中的分支,还有一个名为 production 的分支用于生产,还有一个 master用于分期。

我想要实现的是,每当有人推送到 master 时,应用程序就会被构建然后部署到暂存应用程序,而当有人推送到生产分支时,应用程序就会被构建然后部署到不同的生产应用程序.

我这样配置 .travis.yml 文件:

sudo: false
language: node_js
node_js:
  - '0.10'
env:
  global:
  - GH_REF: github.com/AFusco/MyRepo.git
  - secure: (hidden)
install: "./scripts/install_dependencies.sh"
cache:
   directories:
    - node_modules
    - bower_components

deploy:
  provider: openshift
  skip_cleanup: true
  user: myname@gmail.com
  password:
    secure: (hidden)
  domain: correct_openshift_namespace
  app:
    master: staging
    production: production
after_success: 
  - ./scripts/deploy_app.sh

然而,在我的 ./script/deploy_app.sh

#!/bin/bash
set -ev

rm -rf ./dist
grunt build
cd ./dist
git init
git status
git config --global push.default simple
git config --global user.email "travis@travis-ci.com"
git config --global user.name "Travis CI"
git checkout -b master
git add --all
git commit -am "Travis deploy"

不幸的是,我得到这个错误:

error: src refspec master does not match any.
error: failed to push some refs to 'ssh://45d0ca6189f5cfc35100010c@staging-mynamespace.rhcloud.com/~/git/staging.git/'

我解决了这个问题,我觉得自己像个菜鸟。

因为我提交了 deploy_app.sh 脚本中的所有文件,所以我在脚本完成后没有更改目录,所以 dpl 脚本是在根目录中启动的,而不是在 ./dist

我必须将 .travis.yml 文件更改为:

sudo: false
language: node_js
node_js:
  - '0.10'
env:
  global:
  - GH_REF: github.com/AFusco/MyRepo.git
  - secure: (hidden)
install: "./scripts/install_dependencies.sh"
cache:
   directories:
    - node_modules
    - bower_components

deploy:
  provider: openshift
  skip_cleanup: true
  user: myname@gmail.com
  password:
    secure: (hidden)
  domain: correct_openshift_namespace
  app:
    master: staging
    production: production
after_success: 
  - ./scripts/deploy_app.sh
  - cd ./dist