From 86128d54b468e1e82b6f172daa3ea9e2a681335e Mon Sep 17 00:00:00 2001 From: Adam Mills Date: Thu, 9 Nov 2017 22:15:55 -0500 Subject: [PATCH] Auto deploy base translations with Travis (#599) --- .travis.yml | 9 +++++++++ script/translations_upload_base | 3 +-- script/travis_deploy | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100755 script/travis_deploy diff --git a/.travis.yml b/.travis.yml index 4997bfd8c5..6e3456b544 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,15 @@ script: - npm run test - xvfb-run wct - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct --plugin sauce; fi +services: + - docker +before_deploy: + - docker pull lokalise/lokalise-cli +deploy: + provider: script + script: script/travis_deploy + on: + branch: master dist: trusty addons: sauce_connect: true diff --git a/script/translations_upload_base b/script/translations_upload_base index c915017c03..de64b49b7d 100755 --- a/script/translations_upload_base +++ b/script/translations_upload_base @@ -26,8 +26,7 @@ LANG_ISO=en CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -if [ "$CURRENT_BRANCH" != "master" ] -then +if [ "${CURRENT_BRANCH}" != "master" ] && [ "${TRAVIS_BRANCH}" != "master" ] ; then echo "Please only run the translations upload script from a clean checkout of master." exit 1 fi diff --git a/script/travis_deploy b/script/travis_deploy new file mode 100755 index 0000000000..2f3715aaf5 --- /dev/null +++ b/script/travis_deploy @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +# Safe bash settings +# -e Exit on command fail +# -u Exit on unset variable +# -o pipefail Exit if piped command has error code +set -eu -o pipefail + +cd "$(dirname "$0")/.." + +if git diff "${TRAVIS_COMMIT_RANGE}" --name-only | grep -Fxq "src/translations/en.json" ; then + script/translations_upload_base +else + echo "No changes to src/translations/en.json. Skipping translation upload." +fi