Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CircleCI
committed
Jul 31, 2019
1 parent
7f00663
commit 7cee130
Showing
2 changed files
with
106 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/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" | ||
} | ||
|
||
alias git=/usr/local/bin/git | ||
|
||
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 | ||
|
||
output "${YELLOW}" "Stashing translation.io timestamp file" | ||
set -x | ||
git stash -- config/locales/.translation_io | ||
git status --short | ||
set +x | ||
|
||
if [[ -z "$(git --no-pager diff)" ]]; then | ||
output "${GREEN}" "No uncommitted translations. Done." | ||
exit 0 | ||
else | ||
output "${RED}" "Uncommitted Translations" | ||
git --no-pager diff | ||
|
||
git config user.email "ci@bikeindex.org" | ||
git config user.name "CircleCI" | ||
|
||
output "${YELLOW}" "Committing and pushing translation update" | ||
BRANCH="translation-update-${CIRCLE_BUILD_NUM}" | ||
set -x | ||
git clean --quiet --force -d -x | ||
git stash | ||
git checkout -b ${BRANCH} | ||
git reset --hard origin/master | ||
git stash pop | ||
git stash pop | ||
git add . | ||
git commit -m "Translation update [ci skip]" | ||
git push -u origin ${BRANCH} | ||
set +x | ||
|
||
output "${YELLOW}" "Creating Update Pull Request" | ||
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." | ||
exit 1 | ||
fi |