1
0
mirror of https://github.com/ru-de/faq.git synced 2024-11-08 19:51:01 +00:00
faq-de/files/run_on_master.sh

49 lines
1.3 KiB
Bash
Raw Normal View History

2018-02-13 20:27:17 +00:00
#!/bin/bash
set -e
skip() {
echo "$@" 1>&2
exit 0
}
2018-02-13 21:25:07 +00:00
2018-02-13 22:52:51 +00:00
[ "${TRAVIS_COMMIT_MESSAGE}" == "${TRAVIS_COMMIT_MESSAGE/Travis #/}" ] || \
2018-02-13 21:25:07 +00:00
skip "Skipped... because this is travis autocommit."
2018-02-13 20:27:17 +00:00
[ "${TRAVIS_PULL_REQUEST}" = "false" ] || \
2018-02-13 21:25:07 +00:00
skip "Skipped... because this is pull request."
[ "${TRAVIS_BRANCH}" = "master" ] || \
2018-02-13 21:25:07 +00:00
skip "Skipped... because this is not a master branch (current: ${TRAVIS_BRANCH})."
[ "${TRAVIS_REPO_SLUG}" = "ru-de/faq" ] || \
2018-02-13 21:25:07 +00:00
skip "Skipped... because this is not an original repository (current: ${TRAVIS_REPO_SLUG})."
[ "${GH_TOKEN+set}" = set ] || \
2018-02-13 21:25:07 +00:00
skip "Skipped... GitHub access token not available"
2018-02-13 21:25:07 +00:00
git config --global user.email "travis@travis-ci.org"
git config --global user.name "Travis CI"
git remote add upstream https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git > /dev/null 2>&1
2018-02-13 22:38:50 +00:00
git fetch upstream --depth=3 -q
2018-02-13 21:25:07 +00:00
git checkout upstream/master -q
LC_ALL=ru_RU.UTF8 sort files/dictionary.dic -o files/dictionary.dic -f
if ! git diff --quiet; then
2018-02-13 22:27:05 +00:00
git commit -q -am "Travis #$TRAVIS_BUILD_NUMBER: dictionary rearrangement"
2018-02-13 23:07:23 +00:00
git push -q upstream HEAD:master
2018-02-13 21:25:07 +00:00
echo "Dictionary was rearranged"
fi
git checkout upstream/gh-pages
2018-02-13 23:02:33 +00:00
bash update.sh > /dev/null 2>&1
2018-02-13 21:25:07 +00:00
if ! git diff --quiet; then
2018-02-13 22:27:05 +00:00
git commit -q -am "Travis #$TRAVIS_BUILD_NUMBER: sync github pages"
2018-02-13 23:07:23 +00:00
git push -q upstream HEAD:gh-pages
2018-02-13 21:25:07 +00:00
echo "Github pages was updated"
fi