I'm working on a project that deploys to a provider not currently supported by Travis, so I've written my deployment step in an after_success
block. However, I'd like to configure Travis to only deploy on new tags. I know this is possible when using the deploy:
block, by adding
deploy:
# ...
on:
tags: true
to the deploy:
block.
Is the same possible in after_success
? If not, is there another way to only do certain actions in after_success
if I'm on a new tag?
If Travis doesn't support this, I can just write a shell script to run after all successes, check if on a new tag, and then conditionally do the deployment, but I'd much prefer to be able to have Travis do it automatically.
Thanks!
Yep! I need the exact same thing and worked around it by doing:
after_success:
if ([ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]) &&
[ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "This will deploy!"
else
echo "This will not deploy!"
fi
I hope they introduce the on: tags: functionality for the after_success event, it'll make things easier and keep the build script cleaner.
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