Skip to content

Commit

Permalink
Fixed deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Dec 9, 2018
1 parent f52bc56 commit b02466d
Showing 1 changed file with 14 additions and 24 deletions.
38 changes: 14 additions & 24 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
CURRENT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
WORK_DIR=${CURRENT_DIR}

GIT_BIN=$(command -v git 2>/dev/null)
PHP_BIN=$(command -v php 2>/dev/null)
COMPOSER_BIN=$(command -v composer 2>/dev/null)

Expand All @@ -35,7 +34,7 @@ UPDATE_DOCS=1
PULL_CHANGES=1
CLEAR_CACHE=1

VERSION=0.12.2
VERSION=0.12.3
APP_NAME="Phalcon Docs"

print_version() {
Expand Down Expand Up @@ -75,7 +74,7 @@ print_error() {
printf "${RED}Error: ${1}${NC}\n"
}

print_loales_dirs() {
print_locales_dirs() {
find $(pwd) -maxdepth 1 -type d | grep -v ".git" | grep -v "^.$" | awk -F$(pwd) '{print $2;}' | grep -v "^$" | awk -F'^/' '{print $2;}'
}

Expand All @@ -93,13 +92,6 @@ validate_versions() {
fi
}

validate_git_bin() {
if [[ "x${GIT_BIN}" == "x" ]]; then
print_error "Unable to locate the git bin. Exit..."
exit ${ST_ERR}
fi
}

validate_php_bin() {
if [[ "x${PHP_BIN}" == "x" ]]; then
print_error "Unable to locate the php bin. Exit..."
Expand Down Expand Up @@ -140,11 +132,9 @@ print_versions() {
}

update_docs() {
validate_git_bin

declare docs_path="${WORK_DIR}/docs"
declare versions=$(print_versions)
declare locales=$(print_loales_dirs)
declare locales=$(print_locales_dirs)

if [[ ! -d ${docs_path} ]]; then
print_error "Unable to locate the docs base directory"
Expand All @@ -163,36 +153,35 @@ update_docs() {

pushd "${docs_path}/${version}" &> /dev/null

declare locales=$(print_loales_dirs)
declare locales=$(print_locales_dirs)

${GIT_BIN} checkout -f &> /dev/null
${GIT_BIN} pull origin ${version} &> /dev/null
git checkout -f
git fetch origin --prune
git merge --ff-only origin/${version} || git rebase --preserve-merges origin/${version}

printf "Detected locales in the $version version: " && echo ${locales}
printf "\n"
for locale in ${locales}; do
printf "Going to add missed docs for: ${docs_path}/${version}/${locale}...\n"
printf "Update docs for: ${docs_path}/${version}/${locale} ...\n"
cp -vR ${docs_path}/${version}/en/* ${docs_path}/${version}/${locale}/ > /dev/null 2>&1
done

printf "Discard unwanted changes in working directory: ${docs_path}/${version}\n"
${GIT_BIN} checkout -- .
git checkout -- .

popd &> /dev/null
else
rm -rf "${docs_path}/${version}"
mkdir -p "${docs_path}/${version}"
${GIT_BIN} clone -q -b ${version} --depth=1 "${DOCS_REPO}" "${docs_path}/${version}" &> /dev/null
git clone -q -b ${version} --depth=1 "${DOCS_REPO}" "${docs_path}/${version}" &> /dev/null
fi

printf "Done\n\n"
done
}

pull_latest_changes() {
validate_git_bin

declare current_branch=`${GIT_BIN} rev-parse --abbrev-ref HEAD`
declare current_branch=`git rev-parse --abbrev-ref HEAD`

printf "Current branch is ${YELLOW}${current_branch}${NC}.\n"

Expand All @@ -204,8 +193,9 @@ pull_latest_changes() {

pushd ${WORK_DIR} &> /dev/null

${GIT_BIN} checkout -f &> /dev/null
${GIT_BIN} pull origin ${current_branch} &> /dev/null
git checkout -f
git fetch origin --prune
git merge --ff-only origin/${current_branch} || git rebase --preserve-merges origin/${current_branch}

popd &> /dev/null
fi
Expand Down

0 comments on commit b02466d

Please sign in to comment.