I have a open-source project and i want to deploy the code just if the code is in the master branch, i already tried many approachs, like:
- if [[ $TRAVIS_BRANCH == 'master' ]]; then fab deploy; fi
Or something like:
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.")
But this not work, even in the other peoples branches, the fab deploy
command was triggered.
I'm not sure why your first approach doesn't work but I would suggest using the deploy:
directive in your .travis.yml file with a custom deployment script like this:
deploy:
provider: script
script: scripts/deploy.sh
on:
branch: master
Here is the documentation.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With