0

I want to use Laravel Envoy to deploy my Laravel app, but my staging server has the Laravel project in a different path to where it is on the Production server.

So I've got something like this in Envoy.blade.php

@servers(['staging' => ['user@staging-domain.com'], 'production' => ['user@production-domain.com']])

@task('deploy', ['on' => 'staging'])

    @if ($on === 'staging')
        cd /my/staging/path
    @elseif ($on === 'production')
        cd /my/production/path
    @endif

@endtask

But $on doesn't work - it doesn't tell me what server we're on.

Is there a way to know what server I'm 'on', according to the Envoy deploy task?

Brendan White
  • 435
  • 2
  • 8
  • 17
  • This is (more or less) a duplicate of [this question](https://stackoverflow.com/questions/68189651/deploy-to-multiple-servers-with-different-project-roots-using-laravel-envoy) ... but that other question hasn't been answered either. :-( – Brendan White Jul 19 '22 at 00:13
  • So [this line of code](https://github.com/laravel/envoy/blob/7aeb1614fcd3b0681bde74f49a19b514611c93cc/src/TaskContainer.php#L137) means I can use `$__container` to get to the `Laravel\Envoy\TaskContainer`. Which is great, but it only shows the servers you **can** run the task for, not the server that you are **actually** running it for. So in my example, it returns both Staging and Production, even though we're only running the task on one of those. – Brendan White Jul 19 '22 at 10:58

0 Answers0