4
我有一個開源項目,我要部署的代碼只是如果代碼是在主分支,我已經嘗試了許多技術途徑,如:如何僅在travis-ci中的主分支中運行命令?
- if [[ $TRAVIS_BRANCH == 'master' ]]; then fab deploy; fi
或者喜歡的東西:
BRANCH = "master"
def _get_local_branch():
return local("git rev-parse --abbrev-ref HEAD", capture=True)
def deploy():
local_branch = _get_local_branch()
if local_branch == BRANCH:
print green("Deploy succefully done!")
print yellow("Deploy allowed just in the master branch.")
但這不起作用,即使在其他人的分支中,fab deploy
命令也被觸發。