deploy-phpdoc.sh 1.0 KB

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env bash
  2. set -e
  3. # parameters
  4. GITHUB_PROJECT="$1" # GitHub repo (e.g. picocms/Pico)
  5. GITHUB_BRANCH="$2" # branch to use (e.g. gh-pages)
  6. GITHUB_OAUTH_TOKEN="$3" # see https://github.com/settings/tokens
  7. SOURCE_DIR="$4" # absolute path to phpDocs target directory
  8. TARGET_DIR="$5" # relative path within the specified GitHub repo
  9. # clone repo
  10. GIT_DIR="$(dirname "$0")/$(basename "$SOURCE_DIR").git"
  11. git clone -b "$GITHUB_BRANCH" "https://github.com/$GITHUB_PROJECT.git" "$GIT_DIR"
  12. # setup git
  13. cd "$GIT_DIR"
  14. git config user.name "Travis CI"
  15. git config user.email "travis-ci@picocms.org"
  16. # copy phpdoc
  17. [ -e "$TARGET_DIR" ] && echo "FATAL: $(basename "$0") target directory exists" && exit 1
  18. cp -R "$SOURCE_DIR" "$TARGET_DIR"
  19. # commit changes
  20. git add "$TARGET_DIR"
  21. git commit -m "Add phpDocumentor class docs for Pico $TRAVIS_TAG"
  22. # push changes
  23. git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@github.com/$GITHUB_PROJECT.git" "$GITHUB_BRANCH:$GITHUB_BRANCH" > /dev/null 2>&1