diff --git a/_build/deploy-phpdoc-branch.sh b/_build/deploy-phpdoc-branch.sh index b3238a0..8687170 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 1f7b8c5..3384192 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 e478242..d1aed73 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 9d4e08b..993631a 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 0000000..cce661d --- /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