phpDocs auto deployment: Cleanup
This commit is contained in:
parent
2306010ba7
commit
17dbc4cf18
17
.travis.yml
17
.travis.yml
@ -17,27 +17,16 @@ install:
|
|||||||
- composer install
|
- composer install
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export PATH="$TRAVIS_BUILD_DIR/vendor/bin:$PATH"
|
- export PATH="$TRAVIS_BUILD_DIR/build:$TRAVIS_BUILD_DIR/vendor/bin:$PATH"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- find . -not \( -path './vendor' -prune \) -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null
|
- find . -not \( -path './vendor' -prune \) -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- |
|
- deploy-phpdoc-branch.sh
|
||||||
[ "$TRAVIS_PHP_VERSION" != "5.3" ] && echo "Skipping phpDoc deployment because this is not on the required runtime" && exit
|
|
||||||
[[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]] && echo "Skipping phpDoc deployment because this branch is not permitted to deploy" && exit
|
|
||||||
[ "$TRAVIS_SECURE_ENV_VARS" != "true" ] && echo "Skipping phpDoc deployment because this is no environment with write access to the repository" && exit
|
|
||||||
PHPDOC_ID="${TRAVIS_BRANCH//\//_}"
|
|
||||||
./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)" || exit 1
|
|
||||||
./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "phpDoc/$PHPDOC_ID" "gh-pages" || exit 1
|
|
||||||
|
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- |
|
- deploy-phpdoc-release.sh
|
||||||
[ "$DEPLOY_PHPDOC_TAGS" == "true" ] && (
|
|
||||||
PHPDOC_ID="${TRAVIS_BRANCH//\//_}"
|
|
||||||
./build/generate-phpdoc.sh "$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "Pico 1.0 API Documentation ($TRAVIS_TAG)" || exit 1
|
|
||||||
./build/deploy-phpdoc.sh "$TRAVIS_REPO_SLUG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" "$TRAVIS_TAG" "phpDoc/$PHPDOC_ID" "gh-pages" || exit 1
|
|
||||||
)
|
|
||||||
- composer install --no-dev --optimize-autoloader
|
- composer install --no-dev --optimize-autoloader
|
||||||
- tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php
|
- tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php
|
||||||
|
|
||||||
|
28
build/deploy-phpdoc-branch.sh
Executable file
28
build/deploy-phpdoc-branch.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ "$TRAVIS_PHP_VERSION" != "5.3" ]; then
|
||||||
|
echo "Skipping phpDoc deployment because this is not on the required runtime"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]]; then
|
||||||
|
echo "Skipping phpDoc deployment because this branch is not permitted to deploy"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$TRAVIS_SECURE_ENV_VARS" != "true" ]; then
|
||||||
|
echo "Skipping phpDoc deployment because this is no environment with write access to the repository"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
PHPDOC_ID="${TRAVIS_BRANCH//\//_}"
|
||||||
|
|
||||||
|
generate-phpdoc.sh \
|
||||||
|
"$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \
|
||||||
|
"Pico 1.0 API Documentation ($TRAVIS_BRANCH branch)"
|
||||||
|
[ $? -eq 0 ] || exit 1
|
||||||
|
|
||||||
|
deploy-phpdoc.sh \
|
||||||
|
"$TRAVIS_REPO_SLUG" "$TRAVIS_BRANCH @ $TRAVIS_COMMIT" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \
|
||||||
|
"$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID"
|
||||||
|
[ $? -eq 0 ] || exit 1
|
15
build/deploy-phpdoc-release.sh
Executable file
15
build/deploy-phpdoc-release.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
[ "$DEPLOY_PHPDOC_RELEASES" == "true" ] || exit
|
||||||
|
|
||||||
|
PHPDOC_ID="${TRAVIS_BRANCH//\//_}"
|
||||||
|
|
||||||
|
generate-phpdoc.sh \
|
||||||
|
"$TRAVIS_BUILD_DIR" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \
|
||||||
|
"Pico 1.0 API Documentation ($TRAVIS_TAG)"
|
||||||
|
[ $? -eq 0 ] || exit 1
|
||||||
|
|
||||||
|
deploy-phpdoc.sh \
|
||||||
|
"$TRAVIS_REPO_SLUG" "$TRAVIS_TAG" "$TRAVIS_BUILD_DIR/build/phpdoc-$PHPDOC_ID" \
|
||||||
|
"$TRAVIS_REPO_SLUG" "gh-pages" "phpDoc/$PHPDOC_ID"
|
||||||
|
[ $? -eq 0 ] || exit 1
|
@ -1,25 +1,29 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# base variables
|
||||||
APP_NAME="$(basename "$0")"
|
APP_NAME="$(basename "$0")"
|
||||||
BASE_PWD="$PWD"
|
BASE_PWD="$PWD"
|
||||||
set -e
|
|
||||||
|
|
||||||
# environment variables
|
# environment variables
|
||||||
# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens
|
# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens
|
||||||
|
|
||||||
# parameters
|
# parameters
|
||||||
GITHUB_SLUG="$1" # GitHub repo (e.g. picocms/Pico)
|
SOURCE_REPO_SLUG="$1" # source GitHub repo (e.g. picocms/Pico)
|
||||||
SOURCE_DIR="$2" # absolute source path
|
SOURCE_REF="$2" # source reference (either [branch]@[commit], [branch] or [tag])
|
||||||
SOURCE_REF="$3" # source reference (either [branch]@[commit], [branch] or [tag])
|
SOURCE_DIR="$3" # absolute source path
|
||||||
TARGET_DIR="$4" # relative target path
|
TARGET_REPO_SLUG="$4" # target GitHub repo (e.g. picocms/Pico)
|
||||||
TARGET_BRANCH="$5" # target branch (e.g. gh-pages)
|
TARGET_BRANCH="$5" # target branch (e.g. gh-pages)
|
||||||
|
TARGET_DIR="$6" # relative target path
|
||||||
|
|
||||||
# print parameters
|
# print parameters
|
||||||
echo "Deploying phpDocs..."
|
echo "Deploying phpDocs..."
|
||||||
printf 'GITHUB_SLUG="%s"\n' "$GITHUB_SLUG"
|
printf 'SOURCE_REPO_SLUG="%s"\n' "$SOURCE_REPO_SLUG"
|
||||||
printf 'SOURCE_DIR="%s"\n' "$SOURCE_DIR"
|
|
||||||
printf 'SOURCE_REF="%s"\n' "$SOURCE_REF"
|
printf 'SOURCE_REF="%s"\n' "$SOURCE_REF"
|
||||||
printf 'TARGET_DIR="%s"\n' "$TARGET_DIR"
|
printf 'SOURCE_DIR="%s"\n' "$SOURCE_DIR"
|
||||||
|
printf 'TARGET_REPO_SLUG="%s"\n' "$TARGET_REPO_SLUG"
|
||||||
printf 'TARGET_BRANCH="%s"\n' "$TARGET_BRANCH"
|
printf 'TARGET_BRANCH="%s"\n' "$TARGET_BRANCH"
|
||||||
|
printf 'TARGET_DIR="%s"\n' "$TARGET_DIR"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# evaluate target reference
|
# evaluate target reference
|
||||||
@ -46,7 +50,7 @@ fi
|
|||||||
# clone repo
|
# clone repo
|
||||||
printf 'Cloning repo...\n'
|
printf 'Cloning repo...\n'
|
||||||
GIT_DIR="$SOURCE_DIR.git"
|
GIT_DIR="$SOURCE_DIR.git"
|
||||||
git clone --branch="$TARGET_BRANCH" "https://github.com/$GITHUB_SLUG.git" "$GIT_DIR"
|
git clone --branch="$TARGET_BRANCH" "https://github.com/$TARGET_REPO_SLUG.git" "$GIT_DIR"
|
||||||
|
|
||||||
# setup git
|
# setup git
|
||||||
cd "$GIT_DIR"
|
cd "$GIT_DIR"
|
||||||
@ -67,7 +71,7 @@ cp -R "$SOURCE_DIR" "$TARGET_DIR"
|
|||||||
# commit changes
|
# commit changes
|
||||||
printf '\nCommiting changes...\n'
|
printf '\nCommiting changes...\n'
|
||||||
git add --all "$TARGET_DIR"
|
git add --all "$TARGET_DIR"
|
||||||
git commit -m "Update phpDocumentor class docs for $SOURCE_REF"
|
git commit --message="Update phpDocumentor class docs for $SOURCE_REF"
|
||||||
|
|
||||||
# very simple race condition protection for concurrent Travis builds
|
# very simple race condition protection for concurrent Travis builds
|
||||||
# this is no definite protection (race conditions are still possible during `git push`),
|
# this is no definite protection (race conditions are still possible during `git push`),
|
||||||
@ -75,7 +79,7 @@ git commit -m "Update phpDocumentor class docs for $SOURCE_REF"
|
|||||||
if [ "$SOURCE_REF_TYPE" == "commit" ]; then
|
if [ "$SOURCE_REF_TYPE" == "commit" ]; then
|
||||||
# get latest commit
|
# get latest commit
|
||||||
printf '\nRetrieving latest commit...\n'
|
printf '\nRetrieving latest commit...\n'
|
||||||
LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$GITHUB_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r "
|
LATEST_COMMIT="$(wget -O- "https://api.github.com/repos/$SOURCE_REPO_SLUG/git/refs/heads/$SOURCE_REF_BRANCH" 2> /dev/null | php -r "
|
||||||
\$json = json_decode(stream_get_contents(STDIN), true);
|
\$json = json_decode(stream_get_contents(STDIN), true);
|
||||||
if (\$json !== null) {
|
if (\$json !== null) {
|
||||||
if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$SOURCE_REF_BRANCH')) {
|
if (isset(\$json['ref']) && (\$json['ref'] === 'refs/heads/$SOURCE_REF_BRANCH')) {
|
||||||
@ -95,6 +99,6 @@ fi
|
|||||||
|
|
||||||
# push changes
|
# push changes
|
||||||
printf '\nPushing changes...\n'
|
printf '\nPushing changes...\n'
|
||||||
git push "https://github.com/$GITHUB_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH"
|
git push "https://github.com/$TARGET_REPO_SLUG.git" "$TARGET_BRANCH:$TARGET_BRANCH"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user