Skip to content

Commit

Permalink
Move to script
Browse files Browse the repository at this point in the history
  • Loading branch information
CircleCI committed Jul 31, 2019
1 parent 7f00663 commit 88e1662
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 37 deletions.
38 changes: 1 addition & 37 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,43 +68,7 @@ jobs:

- run:
name: Sync translations (only on master by default)
command: |
# Quit as success if not on the branch to be synced
if ! git branch --list | grep "^* ${TRANSLATION_BRANCH}$"; then
echo Skipping: Not on branch ${TRANSLATION_BRANCH}
exit 0
fi
# TODO: Delete test code
echo bundle exec rake translations:sync >> Gemfile
# bundle exec rake translations:sync
if [[ -n `git status --porcelain --short` ]]; then
echo ------------------------
echo Uncommitted translations:
echo ------------------------
git --no-pager diff
echo ------------------------
git config user.email "ci@bikeindex.org"
git config user.name "CircleCI"
BRANCH="translation-update-${CIRCLE_BUILD_NUM}"
git stash
git clean -df
git checkout -b ${BRANCH}
git reset --hard origin/master
git stash pop
git add .
git commit -m "Translation update [ci skip]"
git push -u origin ${BRANCH}
hub pull-request \
-m "[CircleCI] Translation update
Merge to Unblock CircleCI Job ${CIRCLE_BUILD_NUM}: ${CIRCLE_BUILD_URL}
Related: PR ${CIRCLE_PULL_REQUEST}"
exit 1
fi
command: bin/check_translations

# Node dependencies
- restore_cache:
Expand Down
59 changes: 59 additions & 0 deletions bin/check_translations
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

set -e

CYAN="\033[0;36m"
YELLOW="\033[0;33m"
RED="\033[0;31m"
GREEN="\033[0;32m"
NONE="\033[0m"

output() {
printf "\n${1}${2}${NONE}\n\n"
}

output "${CYAN}" "Checking Translations"

# Quit as success if not on the branch to be synced
if ! git branch --list | grep --silent "^* ${TRANSLATION_BRANCH}$"; then
output "${GREEN}" "Skipping: Not on TRANSLATION_BRANCH: ${TRANSLATION_BRANCH}"
exit 0
fi

echo bundle exec rake translation:sync
bundle exec rake translation:sync
echo changes >> Gemfile # TODO: Kill this line

if [[ -z `git status --porcelain --short` ]]; then
output "${GREEN}" "No uncommitted translations. Done."
exit 0
else
output "${RED}" "Uncommitted Translations"
git --no-pager diff

output "${YELLOW}" "Creating Update PR"
git config user.email "ci@bikeindex.org"
git config user.name "CircleCI"

BRANCH="translation-update-${CIRCLE_BUILD_NUM}"
set -x
echo git stash
echo git clean -df
echo git checkout -b ${BRANCH}
echo git reset --hard origin/master
echo git stash pop
echo git add .
echo git commit -m "Translation update [ci skip]"
echo git push -u origin ${BRANCH}
set +x

hub pull-request \
-m "[i18n] Translation update
Merge to unblock CI job ${CIRCLE_BUILD_NUM}: ${CIRCLE_BUILD_URL}
Related: PR ${CIRCLE_PULL_REQUEST}"

output "${GREEN}" "Translation update PR Created: "
output "${GREEN}" "https://github.com/bikeindex/bike_index/pull/new/${BRANCH}"
exit 1
fi

0 comments on commit 88e1662

Please sign in to comment.