Skip to content
New issue

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

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

Already on GitHub? # to your account

run :local deletes local files and directories #489

Closed
KjellMorgenstern opened this issue Dec 6, 2016 · 4 comments
Closed

run :local deletes local files and directories #489

KjellMorgenstern opened this issue Dec 6, 2016 · 4 comments

Comments

@KjellMorgenstern
Copy link

I tried using

run :local do
 # something
end

within the deploy scripts. (in the "deploy do ... end" block, as in the deploy.rb example).
This will delete the local .git directory.
While the comment in the example deploy.rb states that 'run :local' should be used before or after, not during, I still wish there was some kind of protection against this.

Also, lets say we have a task that does local operations, how would the task to be protected from being called within the deploy script? I tried that as well, and it also deleted the local .git directory.

PS: Don't worry, my repo is save. I always wanted to test if the backups work ;-)

KjellMorgenstern referenced this issue in archferns/mina-scp Dec 7, 2016
@KjellMorgenstern
Copy link
Author

KjellMorgenstern commented Dec 7, 2016

One minimal taks to reproduce the issue:

desc "Deploys the current version to the server. Not!"
task :deploy do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:cleanup'
    # uncommenting the line below might delete stuff on your local machine. 
    # The deletion will be triggered with the deploy:cleanup command above. You have been warned.
    #run :local do
      command 'ls .git'
    end
  end
end

And a quick, not yet really verified workaround:

desc "Deploys the current version to the server."
task :deploy do
  deploy do
    run :remote do
      invoke :'git:clone'
      invoke :'deploy:cleanup'
    end
    run :local do
      command 'ls .git'
    end
  end
end

@kuboon
Copy link
Contributor

kuboon commented Dec 9, 2016

I write run(:local) block outside of deploy block (as in this comment-outed line https://github.com/mina-deploy/mina/blob/master/data/deploy.rb#L66) and it works fine.

@d4be4st
Copy link
Member

d4be4st commented Dec 13, 2016

what @kuboon said.

Also you could do a mina deploy -s to see what exacly is being run

@d4be4st d4be4st closed this as completed Dec 13, 2016
@KjellMorgenstern
Copy link
Author

I know that the expected usage is to have the run(:local) block outside of the deploy. But failing to do so is possibly dangerous to the unaware developer. My idea is more aiming at modifying mina to throw an error in case of the described misuse of run(:local). Would it be helpful to directly check wether 'run' calls are nested? Or maybe a semaphore can be added that directly prevents run(:local) calls while in the deploy block.

PS: My original use case for this was to copy over some secrets before the last deploy steps, but after the git clone. Solution was to copy the secrets first (call scp locally), then deploy and create symlinks remotely. This way remote and local steps don't need to be nested.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants