#!/usr/bin/env php 0) { die($returnVar); } } /** * Check if an env variable is set * * @param $envs * @return bool */ function checkenv($envs) { if ($envs) { foreach (explode(',', $envs) as $env) { if (!getenv($env)) { return false; } } } return true; } $opts = getopt('', array( 'artifacts-path:', 'target-path:', 'if-env:', 'artifacts-base-url:', )); // --if-env=BEHAT_TEST means that this script will only be executed if the given environment var is set if (empty($opts['if-env'])) { echo "--if-env option is mandatory"; exit(0); } if (!checkenv($opts['if-env'])) { echo "Apache skipped; {$opts['if-env']} wasn't set.\n"; exit(0); } if (isset($opts['artifacts-path'])) { $artifactsPath = $opts['artifacts-path']; } elseif (is_dir(__DIR__ . '/artifacts/')) { $artifactsPath = __DIR__ . '/artifacts/'; } elseif (is_dir('~/artifacts/')) { $artifactsPath = '~/artifacts/'; } else { $artifactsPath = null; } $targetPath = $opts['target-path']; $baseUrl = $opts['artifacts-base-url']; if (!$artifactsPath || !is_dir($artifactsPath)) { echo "No artifacts found, skipped\n"; exit(0); } echo "Installing artifacts script to ~/bin/artifacts\n"; run("curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash"); echo "Creating {$artifactsPath}index.html...\n"; $html = '