diff --git a/_build/deploy-phpdoc-branch.sh b/_build/deploy-phpdoc-branch.sh index b3238a0783b63a9f1331fe8d1186fc9bcc83c4e0..8687170574d8acf9dd6cf9dd822dd658a61c733f 100755 --- a/_build/deploy-phpdoc-branch.sh +++ b/_build/deploy-phpdoc-branch.sh @@ -26,6 +26,9 @@ git clone --branch="gh-pages" "https://github.com/$TRAVIS_REPO_SLUG.git" "$PHPDO cd "$PHPDOC_GIT_DIR" echo +# setup repo +github-setup.sh + # generate phpDocs generate-phpdoc.sh \ "$TRAVIS_BUILD_DIR/.phpdoc.xml" \ diff --git a/_build/deploy-phpdoc-release.sh b/_build/deploy-phpdoc-release.sh index 1f7b8c5b9d389527f607c6318bc79bc3a36a8674..338419225121c4d44464c444168860192c4f680d 100755 --- a/_build/deploy-phpdoc-release.sh +++ b/_build/deploy-phpdoc-release.sh @@ -13,6 +13,9 @@ git clone --branch="gh-pages" "https://github.com/$TRAVIS_REPO_SLUG.git" "$GIT_D cd "$GIT_DIR" echo +# setup repo +github-setup.sh + # generate phpDocs generate-phpdoc.sh \ "$TRAVIS_BUILD_DIR/.phpdoc.xml" \ diff --git a/_build/generate-badge.sh b/_build/generate-badge.sh index e478242d7838b168f9e540b77e5a605bbfb1166e..d1aed7305d81768474f235054a4d6baa993e3585 100755 --- a/_build/generate-badge.sh +++ b/_build/generate-badge.sh @@ -15,10 +15,10 @@ set -e # parameters -BADGE_FILE_PATH="$1" -BADGE_SUBJECT="$2" -BADGE_STATUS="$3" -BADGE_COLOR="$4" +BADGE_FILE_PATH="$1" # target file path +BADGE_SUBJECT="$2" # subject (left half) of the badge +BADGE_STATUS="$3" # status (right half) of the badge +BADGE_COLOR="$4" # color of the badge # print parameters echo "Generating badge..." diff --git a/_build/github-deploy.sh b/_build/github-deploy.sh index 9d4e08bd8ae0aad978f30bd9eb61a806009a4388..993631aa553efd775fc64248b467658da8fa1e1c 100755 --- a/_build/github-deploy.sh +++ b/_build/github-deploy.sh @@ -10,9 +10,6 @@ set -e -# environment variables -# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens - # parameters CHECK_REPO_SLUG="$1" # optional GitHub repo (e.g. picocms/Pico) to check # its latest commit as basic race condition protection @@ -26,29 +23,12 @@ printf 'CHECK_REMOTE_REF="%s"\n' "$CHECK_REMOTE_REF" printf 'CHECK_LOCAL_COMMIT="%s"\n' "$CHECK_LOCAL_COMMIT" echo -# check for git repo -if ! git rev-parse --git-dir > /dev/null 2>&1; then - printf 'Not a git repo; aborting...\n\n' - exit 1 -fi - # check for changes if [ -z "$(git log --oneline '@{upstream}..')" ]; then printf 'Nothing to deploy; skipping...\n\n' exit 0 fi -# setup git -printf 'Preparing repo...\n' -git config push.default simple -git config user.name "Travis CI" -git config user.email "travis-ci@picocms.org" - -if [ -n "$GITHUB_OAUTH_TOKEN" ]; then - git config credential.helper 'store --file=.git/credentials' - (umask 077 && echo "https://GitHub:$GITHUB_OAUTH_TOKEN@github.com" > .git/credentials) -fi - # race condition protection for concurrent Travis builds # this is no definite protection (race conditions are still possible during `git push`), # but it should give a basic protection without disabling concurrent builds completely diff --git a/_build/github-setup.sh b/_build/github-setup.sh new file mode 100755 index 0000000000000000000000000000000000000000..cce661df6957faf93a59d899beef25fe7917254a --- /dev/null +++ b/_build/github-setup.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +## +# Prepares a GitHub repo for deployment +# +# @author Daniel Rudolf +# @link http://picocms.org +# @license http://opensource.org/licenses/MIT +# + +set -e + +# environment variables +# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens + +# print "parameters" (we don't have any) +echo "Setup repo..." +echo + +# check for git repo +if ! git rev-parse --git-dir > /dev/null 2>&1; then + printf 'Not a git repo; aborting...\n\n' + exit 1 +fi + +# setup git +printf 'Preparing repo...\n' +git config push.default simple +git config user.name "Travis CI" +git config user.email "travis-ci@picocms.org" + +if [ -n "$GITHUB_OAUTH_TOKEN" ]; then + git config credential.helper 'store --file=.git/credentials' + (umask 077 && echo "https://GitHub:$GITHUB_OAUTH_TOKEN@github.com" > .git/credentials) +fi \ No newline at end of file