Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is {{release_path}} still the way to get the current release? #3337

Closed
Azuka opened this issue Oct 9, 2022 · 4 comments
Closed

Is {{release_path}} still the way to get the current release? #3337

Azuka opened this issue Oct 9, 2022 · 4 comments

Comments

@Azuka
Copy link

Azuka commented Oct 9, 2022

  • Deployer version: 7.0.2
  • Deployment OS: OSX/Ubuntu (fails both locally and in ci)
task('link:secrets', function () {
    run('ln -sfn ~/.secrets/.env {{release_path}}/system/.env.common');

    // Staging env
    if (in_array('staging', $stages)) {
        run('ln -sfn ~/.secrets/.env.staging {{release_path}}/system/.env');
    }
    // Production env
    if (in_array('production', $stages)) {
        run('ln -sfn ~/.secrets/.env.production {{release_path}}/system/.env');
    }

})->desc('Symlinks secret files.');

after('deploy:vendors', 'link:secrets');

I recently upgraded from deployer 6 to 7, and had a command that would symlink some env secrets for the current release, so that

  • in the middle of a deploy to say, releases/4, this would symlink a file into releases/4/.env
  • as a one-off, running ./vendor/bin/dep link:secrets stage=staging, {{release_path}} would return the current release and link to it as well.

In both cases, I get the error:

The "release_path" ({{deploy_path}}/release) does not exist.

What's the currently supported method to get the path to the working release? {{release_name}} for the second case returns 5 if the current release is 4.

As of this writing, the implementation of release_name is:

// The name of the release.
set('release_name', function () {
    return within('{{deploy_path}}', function () {
        $latest = run('cat .dep/latest_release || echo 0');
        return strval(intval($latest) + 1);
    });
});

I would prefer not to hack the internals in case something changes in future.

@antonmedv
Copy link
Member

After deploy:release task is executed (deploy process) you can use release_path.

The release_path should point to {{deploy_path}}/release symlink.

But Deployer also has a special param release_or_current_path.

The release_or_current_path can be used during deployment and as in one-off tasks. During deeply release_or_current_path points to release symlink. Otherwise to current symlink.

@Azuka
Copy link
Author

Azuka commented Oct 9, 2022

Thanks for the quick reply. I'd really like to symlink secrets before completing the release so I don't catch clients trying to access the site during a release.

Another question: is there any way to detect if I'm in the middle of a release or not, assuming {{release_or_current_path}} doesn't work?

@antonmedv
Copy link
Member

Easiest was to check if release exists is:

$releaseExists = test('[ -h {{deploy_path}}/release ]');

@Azuka
Copy link
Author

Azuka commented Oct 11, 2022

The release_or_current_path can be used during deployment and as in one-off tasks. During deeply release_or_current_path points to release symlink. Otherwise to current symlink.

I just realized that means I can readlink {{release_or_current_path}}. I'll combine that with everything else and get it working.

@Azuka Azuka closed this as completed Dec 19, 2022
jsnmrs pushed a commit to jsnmrs/aggro that referenced this issue Jan 14, 2023
jsnmrs pushed a commit to jsnmrs/aggro that referenced this issue Jan 14, 2023
* Change path references

via deployphp/deployer#3337 (comment)

* Remove release, included in prepare

via deployphp/deployer#3301 (comment)

* Update deployer to 7.1.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants