Build scripts: Git identity must be configured before committing

This commit is contained in:
Daniel Rudolf 2016-01-14 13:12:10 +01:00
parent 8554c0a60d
commit cd0e0f706f
5 changed files with 45 additions and 24 deletions

View file

@ -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" \

View file

@ -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" \

View file

@ -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..."

View file

@ -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

35
_build/github-setup.sh Executable file
View file

@ -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