diff --git a/.environment b/.environment index 3e001416..c471d0f3 100644 --- a/.environment +++ b/.environment @@ -9,3 +9,6 @@ if [ -n "$PLATFORM_APP_DIR" -a -f "$PLATFORM_APP_DIR"/composer.json ] ; then bin=$(composer config bin-dir --working-dir="$PLATFORM_APP_DIR" --no-interaction 2>/dev/null) export PATH="${PLATFORM_APP_DIR}/${bin:-vendor/bin}:${PATH}" fi + +# Set the default site URL for drush. +export DRUSH_OPTIONS_URI=$(echo $PLATFORM_ROUTES | base64 --decode | jq -r "to_entries | map(select(.value.upstream == \"$PLATFORM_APPLICATION_NAME\")) | sort_by(.value.primary, .key) | reverse | [.[].key] | first") \ No newline at end of file diff --git a/.platform.app.yaml b/.platform.app.yaml index 7a63cc7d..aab961ab 100644 --- a/.platform.app.yaml +++ b/.platform.app.yaml @@ -80,7 +80,6 @@ hooks: # fast. deploy: | set -e - php ./drush/platformsh_generate_drush_yml.php # if drupal is installed, will call the following drush commands: # - `cache-rebuild` # - `updatedb` diff --git a/drush/platformsh_generate_drush_yml.php b/drush/platformsh_generate_drush_yml.php deleted file mode 100644 index 9dbb98c1..00000000 --- a/drush/platformsh_generate_drush_yml.php +++ /dev/null @@ -1,80 +0,0 @@ -inRuntime()) { - return; - } - - $routes = $platformsh->getUpstreamRoutes($platformsh->applicationName); - - // Sort URLs, with the primary route first, then by HTTPS before HTTP, then by length. - usort($routes, function (array $a, array $b) { - // false sorts before true, normally, so negate the comparison. - return - [!$a['primary'], strpos($a['url'], 'https://') !== 0, strlen($a['url'])] - <=> - [!$b['primary'], strpos($b['url'], 'https://') !== 0, strlen($b['url'])]; - }); - - // Return the url of the first one. - return reset($routes)['url'] ?: NULL; -} - -$appRoot = dirname(__DIR__); -$filename = $appRoot . '/.drush/drush.yml'; - -$siteUrl = _platformsh_drush_site_url(); - -if (empty($siteUrl)) { - echo "Failed to find a site URL\n"; - - if (file_exists($filename)) { - echo "The file exists but may be invalid: $filename\n"; - } - - exit(1); -} - -$siteUrlYamlEscaped = json_encode($siteUrl, JSON_UNESCAPED_SLASHES); -$scriptPath = __FILE__; - -$success = file_put_contents($filename, <<