Build all the JS on CI success

This commit is contained in:
Clemens Wolff 2017-06-13 11:37:11 +02:00
Родитель 6fcba3c3d8
Коммит 864a92a1e7
2 изменённых файлов: 54 добавлений и 1 удалений

Просмотреть файл

@ -8,4 +8,7 @@ install:
- .travis/setup.sh
script:
- .travis/ci.sh
- .travis/ci.sh
after_success:
- .travis/push.sh

50
.travis/push.sh Executable file
Просмотреть файл

@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -euo pipefail
readonly GITHUB_ORG="${GITHUB_ORG:-CatalystCode}"
readonly GITHUB_REPO="${GITHUB_REPO:-ibex-dashboard}"
readonly TARGET_BRANCH="${TARGET_BRANCH:-master}"
log() {
echo "$@" >&2
}
ensure_preconditions_met() {
if [ "${TRAVIS_BRANCH}" != "${TARGET_BRANCH}" ]; then
log "Build is targetting ${TRAVIS_BRANCH}, not ${TARGET_BRANCH}"
log "Skipping creation of production build"
exit 0
fi
if [ -z "${GITHUB_TOKEN}" ]; then
log "GITHUB_TOKEN not set: won't be able to push production build"
log "Please configure the token in .travis.yml or the Travis UI"
exit 1
fi
}
create_production_build() {
CI="" yarn build
}
setup_git() {
git config user.name "Travis CI"
git config user.email "travis@travis-ci.org"
git remote add origin-travis "https://${GITHUB_TOKEN}@github.com/${GITHUB_ORG}/${GITHUB_REPO}.git"
}
commit_build_files() {
git checkout "${TARGET_BRANCH}"
git add --all build
echo -e "Travis build: ${TRAVIS_BUILD_NUMBER}\n\nhttps://travis-ci.org/${GITHUB_ORG}/${GITHUB_REPO}/builds/${TRAVIS_BUILD_ID}" | git commit --file -
}
push_to_github() {
git push origin-travis "${TARGET_BRANCH}:${TARGET_BRANCH}"
}
ensure_preconditions_met
create_production_build
setup_git
commit_build_files
push_to_github