Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #11 from okta/develop
Browse files Browse the repository at this point in the history
Version 0.1.0
  • Loading branch information
bretterer authored Jun 27, 2017
2 parents 679cfac + 8995555 commit 09f3477
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 14 deletions.
47 changes: 33 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- COVERAGE=true
- SETUP=stable
- DEPLOY_DOCS=true
27 changes: 27 additions & 0 deletions sami.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Sami\Sami;
use Symfony\Component\Finder\Finder;
use Sami\Version\GitVersionCollection;
use Sami\RemoteRepository\GitHubRemoteRepository;

$dir = __DIR__ . '/src';

$iterator = Finder::create()
->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)),
]);
32 changes: 32 additions & 0 deletions scripts/create-redirector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Adapted from contentful.php
*/
$travisRepoSlug = getenv('TRAVIS_REPO_SLUG');
$indexFile = $argv[1];

$shellOutput = shell_exec('git tag');
$tags = explode("\n", $shellOutput);
$tags = array_filter($tags, function ($tag) {
return trim($tag) !== '';
});

// We remove all non-stable versions from the list as we don't want to direct the docs to them by default
$tags = array_filter($tags, function ($tag) {
return strpos($tag, '-') === false;
});

usort($tags, function ($a, $b) {
return version_compare($b, $a);
});

$newestTag = $tags[0];
$repoParts = explode('/', $travisRepoSlug);
$repoOwner = $repoParts[0];
$repoName = $repoParts[1];

$html = '<meta http-equiv="refresh" content="0; url=https://developer.okta.com/' . $repoName . '/' . $newestTag . '/">';

file_put_contents($indexFile, $html);

echo 'Created index file redirecting to ' . $newestTag . '.' . "\n";
9 changes: 9 additions & 0 deletions scripts/prepare-docs.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 09f3477

Please sign in to comment.