diff --git a/.travis.yml b/.travis.yml index 4addc632f6..d1960e1b99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,33 +2,52 @@ language: php env: global: - - coverage=false - - setup=basic + - COVERAGE=false + - SETUP=basic + - DEPLOY_DOCS=false install: - - if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction --no-suggest; fi - - if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable; fi - - if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable --prefer-lowest; fi + - if [[ $SETUP = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction --no-suggest; fi + - if [[ $SETUP = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable; fi + - if [[ $SETUP = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable --prefer-lowest; fi before_script: -- mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc -- mkdir -p ~/.okta + - mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc + - mkdir -p ~/.okta script: -- vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml + - vendor/bin/phpunit --verbose --coverage-clover build/logs/clover.xml after_success: - - if [[ $coverage = 'true' ]]; then bash <(curl -s https://codecov.io/bash); fi + - if [[ $COVERAGE = 'true' ]]; then bash <(curl -s https://codecov.io/bash); fi + - if [[ $DEPLOY_DOCS ]]; then wget -O sami.phar http://get.sensiolabs.org/sami.phar; fi; + - if [[ $DEPLOY_DOCS ]]; then chmod +x ./scripts/prepare-docs.sh; fi + - if [[ $DEPLOY_DOCS ]]; then ./scripts/prepare-docs.sh; fi + +deploy: + provider: pages + skip_cleanup: true + github_token: $GITHUB_TOKEN + local_dir: full/build/gh-pages + email: deploy-php@okta.com + name: PHP Deployment Bot + on: + php: 7.1 + tags: true + branch: + - develop + - master matrix: include: - php: 7.0 - env: setup=lowest + env: SETUP=lowest - php: 7.0 - env: setup=stable + env: SETUP=stable - php: 7.1 - env: setup=lowest + env: SETUP=lowest - php: 7.1 env: - - coverage=true - - setup=stable \ No newline at end of file + - COVERAGE=true + - SETUP=stable + - DEPLOY_DOCS=true diff --git a/sami.php b/sami.php new file mode 100644 index 0000000000..656dcb5523 --- /dev/null +++ b/sami.php @@ -0,0 +1,27 @@ +files() + ->name('*.php') + ->in($dir) +; + + +$versions = GitVersionCollection::create($dir) + ->addFromTags('*') +; + +return new Sami($iterator, [ + 'title' => 'Okta PHP SDK', + 'versions' => $versions, + 'build_dir' => __DIR__ . '/build/gh-pages/%version%', + 'cache_dir' => __DIR__ . '/build/doc_cache/%version%', + 'remote_repository' => new GitHubRemoteRepository('okta/okta-sdk-php', dirname($dir)), +]); diff --git a/scripts/create-redirector.php b/scripts/create-redirector.php new file mode 100644 index 0000000000..f9f1c668bb --- /dev/null +++ b/scripts/create-redirector.php @@ -0,0 +1,32 @@ +'; + +file_put_contents($indexFile, $html); + +echo 'Created index file redirecting to ' . $newestTag . '.' . "\n"; diff --git a/scripts/prepare-docs.sh b/scripts/prepare-docs.sh new file mode 100644 index 0000000000..eedd7a9009 --- /dev/null +++ b/scripts/prepare-docs.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +git clone https://github.com/${TRAVIS_REPO_SLUG}.git full +cd full +git checkout ${TRAVIS_TAG} +php ../sami.phar update sami.php +git checkout ${TRAVIS_TAG} +mkdir build/gh-pages/latest +php scripts/create-redirector.php build/gh-pages/latest/index.html +php scripts/create-redirector.php build/gh-pages/index.html